Hello friends,
I am using a Tree View which have many nodes,Now my problem is dat when I made any data entry against any of the node,color of that node should changed so dat I know against which node I am doing entry .. means onle active node's color should be changed.
Sourabh SharmaPosted Apr 3, 2008, 11:47 PM
Hi Scott,
thanks for ur reply...I hope so it will work, but i choose another way to know my answer...Guess wat??
I put the value of current style into a label and make it visible wen clicking on any particular style...bu now I will try to use ur method.
Thanks 4 ur help.
Scott LyslePosted Apr 3, 2008, 1:14 PM
The following code will find a node and highlight it.
private void btnFindNode_Click(object sender, EventArgs e) { ClearBackColor(); try { TreeNode[] tn = treeView1.Nodes[0].Nodes.Find(txtNodeSearch.Text, true); for (int i = 0; i < tn.Length; i++) { treeView1.SelectedNode = tn[i]; treeView1.SelectedNode.BackColor = Color.Yellow; } } catch { } } // recursively move through the treeview nodes // and reset backcolors to white private void ClearBackColor() { TreeNodeCollection nodes = treeView1.Nodes; foreach (TreeNode n in nodes) { ClearRecursive(n); } } // called by ClearBackColor function private void ClearRecursive(TreeNode treeNode) { foreach (TreeNode tn in treeNode.Nodes) { tn.BackColor = Color.White; ClearRecursive(tn); } }