Results 1 to 3 of 3

Thread: Treeview Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belgium
    Posts
    167

    Treeview Problem

    I'm making a program that uses a treeview as a menu.
    But my question is: if i have on the left side of my program a treeview with different nodes that operates as a menu how can i make some sort of tabcontroll of it?

    for example: if i click on Setup different objects come's visable, if i click on a other node the objects of Setup becomes invisable and the one's of the node becomes visable.

    What i do now is use a groupbox and everything form setup I put in a groupbox. but i have like 20 nodes so that would be allot of groupboxes and allot of small piece's of code.

    How would i solve that?

  2. #2
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: Treeview Problem

    I'm not sure if i understand you problem. Are you saying that in a tree view if you have one node and you click on another node, that node minimizes and the node that was clicked on expands?? Could you please explain a little more because the tree views I have done does not work like that, if you click on a node only that node expands or minimizes.

    What you mean by tab control???

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

    Re: Treeview Problem

    You have two feasible options in my opinion.

    Firstly, you could put multiple containers on the right-hand side at design time. Containers include Panels, GroupBoxes, etc. It is not difficult to work with multiple containers on top of each other but you just need to be careful when adding them in the first place to make sure that they're all added to the form and not inside each other. Once you have them all on the form you just use SendToback and BringToFront to manipulate the z-order. At run-time you simply set the appropriate Visible properties so that just the one you want is visiable. The advnatage of this method is that all the controls and data are on your form all the time, so if you switch back and forth between containers there is no need to reload data. The issue is that your form is very control heavy.

    Secondly, you could design a UserControl for each of the groups of controls you want. When you make a selection in the menu you remove the current control from the right-hand side and create an instance of the one that corresponds to the current selection, then add it to the form. The advantage of this method is that you only have the controls on the form for one option at a time, so it's less resource intensive as you're using it. The disadvantage is that each time you change the menu selection you have to create and destroy complex objects, plus reload any data required.

    The better option really depends on your situation and your preference.
    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

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