Different controls in the content of each node of the TreeView

1

I am creating this Search form that basically contains a TreeView with several nodes as I show you in the following image:

The objective is that when clicking on each node, different controls appear in the panel on the right, that is, as if they were individual pages with their own controls, I do not know if I explain.

For example, in Name I want that TextBox and some CheckBox for the user to choose if he wants sensitivity to mayus / minus or not. But in Category I want a list or multiple CheckBox to select the category of contacts that you want to filter in the list, eg. personal, family, work, etc.

    
asked by AlexMnrs 03.08.2016 в 10:11
source

1 answer

1

When you created the treeview nodes you could assign the property Tag with the user control instance that should be used in the panel on the right

then in the node selection event you would use

private void TreeView1_BeforeSelect(Object sender, TreeViewCancelEventArgs e) {

    UserControl uc = e.Node.Tag as UserControl;
    Panel1.Controls.Add(uc);

}

TreeNode.Tag Property

assigning the Tag you can put contextual information to the data of the node to know which user control you should show ne each case. When the Name node is assigned the user control that shows the textbox

    
answered by 03.08.2016 / 19:03
source