Saturday, February 13, 2010

How to traverse a node in C#















This segment is from the NetPinger 2010 Application and traverses the Node. I've updated the interface a little bit.

void traverseNode(TreeNode node1)

{

foreach (TreeNode tn1 in node1.Nodes)

{

if (tn1.Text.Length <>"CN")

{

lblCover.Image = NetPinger.Properties.Resources.On1;

this.treePing.SelectedNode = tn1;

mnuNotify.ShowBalloonTip(1000,

"NetPinger 2010",

tn1.Text,

ToolTipIcon.Info);

toolStripStatusLabel1.Text = tn1.Text;

if (this.treePing.SelectedNode.ForeColor != Color.LawnGreen)

{

if (this.treePing.SelectedNode.ForeColor != Color.OrangeRed)

{

if (tn1.Text.Substring(0, 2) == "CN")

{

String temp1 =

this.treePing.SelectedNode.Text.Substring(3);

String temp2 =

this.treePing.SelectedNode.Parent.Text.Substring(3);

selectMe();

}

}

}

if (tn1.Text.Substring(0, 2) == "OU") traverseNode(tn1);

}

}

}

No comments:

Post a Comment