Home > Net >  For help! Treeview and combox cascading menus
For help! Treeview and combox cascading menus

Time:02-11

Consult a problem bosses: first of all, I will manually enter and create a tree as shown in figure:
I have created two combox do then cascading menu [img=https://img-


How will the two combox according to create parent-child cascading menu tree to do?
Ask bosses

CodePudding user response:

CodePudding user response:

Vb.net plate before someone wants to triple linkage wrote a demo
Link: https://pan.baidu.com/s/1qGC7Bk-1fncBHdwWOtkZzg
The extracted code: 7 PLM
You can download a tool to c # for your reference,

CodePudding user response:

Private void button13_Click (object sender, EventArgs e)
{
Var list=treeView1. Nodes
. Cast ()
The Select (x=& gt; X.T ext)
ToList ();

ComboBox1. The DataSource=list;
Var Clist=treeView1. Nodes [0]. Nodes
. Cast ()
The Select (x=& gt; X.T ext)
ToList ();

ComboBox2. The DataSource=Clist;

}


Has now been achieved by the above code will be the parent node in the first combox, but the second sent by selectchange child did not change is problematic code below:
Private void comboBox1_SelectedIndexChanged_1 (object sender, EventArgs e)
{
Var node=comboBox1. SelectedItem as TreeNode;
If (node==null)
return;
TreeView1. Focus ();
TreeView1. SelectedNode=node;
}
  •  Tags:  
  • C#
  • Related