|
-
Nov 10th, 2008, 11:20 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] More usercontrol questions
Hi all,
after some great advice from this form i decided to take a win form that had like 500 text boxes and make a user control to help group things a little better
Its going along swimmingly but i have one question before i get two deep into things
right now i have 4 user controls but they are almost exactly the same they just differ slightly on layout and one has 4 extra labels and 2 extra text boxes
I think from a maintenance point of view it would be nice to have all the code I need in one user control and " morph" it into the control appearance I need at run time by saying something like usercontol1.type(4) or .type(1) then from a select switch in the control move/enable the sub controls I need.
So the question before the forums is:
is there a better way to create one user control that i can change the shape of
if so what is the best way
thanks alot
Robert
-
Nov 10th, 2008, 06:41 PM
#2
Re: More usercontrol questions
You may have heard of inheritance. UserControls are classes. Just like every other class they can inherit and be inherited. All your UserControls already inherit the UserControl class. You can simply create another UserControl that inherits the first one and adds to and/or modifies its behaviour.
-
Nov 11th, 2008, 07:09 AM
#3
Frenzied Member
Re: More usercontrol questions
Thats what the linked code in my sig does it takes a label and a panel and changes them for my own mischievous purposes. The label link is a tutorial and the label/panel link is just source code.
Have a look
-
Nov 11th, 2008, 07:12 AM
#4
Frenzied Member
Re: More usercontrol questions
PS the code is VB you can paste it here http://www.developerfusion.com/tools.../vb-to-csharp/ to c# it. Ive done it already to test and it works fine.
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
|