|
-
Nov 14th, 2005, 03:05 AM
#1
Thread Starter
Fanatic Member
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
-
Nov 14th, 2005, 03:58 AM
#2
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
-
Nov 14th, 2005, 07:10 AM
#3
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.
-
Nov 15th, 2005, 10:14 AM
#4
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.
-
Nov 15th, 2005, 12:45 PM
#5
Re: user control info
 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?
-
Nov 15th, 2005, 05:07 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|