Results 1 to 6 of 6

Thread: user control info

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    user control info

    hi,
    Anyone can give a detail or information about user control in C#. About its purpose, when its the right time to use that class?

    thnks in advance,

    Popskie

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: user control info

    UserControl is a class you must inherit. It should be used when no control or combination of controls will do what you want. There are examples in the Codebank of user controls.

    Typically though, as I have had spanked into me many times on these forums, it's not necessary to reinvent the wheel. Look at what's available, and if you have a set purpose in mind you cannot fulfill with the frameworks controls, you make a user control.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: user control info

    A UserControl is generally just a way to group existing controls into a single unit that can be reused and can hide some of the lower-level functionality behind public members of the control itself. If you want genuinely new functionality then you would normally inherit an existing control and override existing members or add new ones. These are not hard and fast rules of course, but in my experience this is the way it happens in the bulk of circumstances.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: user control info

    An example would be if you want a textbox to allow only numeric inputs that fall below 666, and if you use this control all over your project. That'd warrant the creation of a user contorl.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: user control info

    Quote Originally Posted by mendhak
    An example would be if you want a textbox to allow only numeric inputs that fall below 666, and if you use this control all over your project. That'd warrant the creation of a user contorl.
    For that wouldn't it be easier to derive the new control from the Textbox, rather than creating a new one?

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: user control info

    Yes, and obviously I did not think my answer very well before posting it. Thanks for pointing it out.

    You always do this to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width