custom and user controls RRS feed

  • Question

  • i know this sounds really stupid but what exactly are user and custom controls and how do they work?
    Monday, March 19, 2007 12:33 AM


  • Assuming we're talking windows not web...

    user controls are composite controls ie. you create one control that contains other controls so you can encompase re-occurring functionality on one control.  Good example would be an Address user control.  You would create a control that has a number of textboxes and labels on it that allow you to capture address information.  That way if you wanted to have several forms capturing address information, you can just drop your new user control onto the form instead of having to drop several textboxes onto the form.

    A custom control is typically used when you want to create your own control that cannot be built simply by dropping other existing controls onto the designer.  I use custom controls for special controls that I want to render myself.  These controls would either inherit an existing control and override its base methods (e.g. inherit a textbox and override its keypress method to turn it into a numeric textbox) or be used to create an entirely new control from scratch.

    Hope this helps!


    Monday, March 19, 2007 3:21 PM