Results 1 to 4 of 4

Thread: [RESOLVED] More usercontrol questions

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [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

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

    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.
    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

  3. #3
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    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

  4. #4
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    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
  •  



Click Here to Expand Forum to Full Width