110,539
社区成员
发帖
与我相关
我的任务
分享
#region TreeView AfterSelect Event.
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
this.getCon();
string name = this.treeView1.SelectedNode.Text.ToString();
this.treeView1.SelectedNode.Nodes.Clear(); // Clear the selected node's children nodes.
SortedList<string, int> childern = findUnder(name); // Find the child nodes from the data.
foreach (KeyValuePair<string, int> s in childern)
{
if (data.Contains(s.Key)) // Check the srearch contain the nodes.
{
TreeNode child = new TreeNode(s.Key.ToString());
this.treeView1.SelectedNode.Nodes.Add(child); // Add the found nodes into the selected node.
data.Remove(s.Key);
}
}
for (int k = 0; k < data.Count; k++)
{
TreeNode child = new TreeNode(data[k].ToString());
this.treeView1.Nodes.Add(child);
}
this.treeView1.SelectedNode.Expand();
this.showInfo(name); // Show the selected node's information.
this.odcConnection.Close();// Close the data connection.
}