I finally stumbled upon how to do this. I added code to the BeforeLabelEdit and AfterLabelEdit code to save the original text stored in the node and compare it to the new text being input.
CODE
string beforeEdit = "";
string afterEdit = "";
private void treeView3_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
{
BeforeTreeEdit(treeView3, sender, e);
}
private void treeView3_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
AfterTreeEdit(treeView3, sender, e);
}
private void BeforeTreeEdit(TreeView Tree, object sender, NodeLabelEditEventArgs e)
{
// Determine whether the user has selected the top node. If so,
// change the LabelEdit property to false so the user cannot
// edit this label.
if (e.Node == Tree.TopNode)
{
Tree.LabelEdit = false;
MessageBox.Show("You are not allowed to edit the top node", "Illegal Node", MessageBoxButtons.OK);
}
// Allow the user to edit only the Value node
else if (e.Node.Level < 2)
{
Tree.LabelEdit = false;
MessageBox.Show("This node cannot be edited", "Illegal Node", MessageBoxButtons.OK);
}
Tree.LabelEdit = true;
beforeEdit = e.Node.ToString();
}
private void AfterTreeEdit(TreeView Tree, object sender, NodeLabelEditEventArgs e)
{
afterEdit = e.Label;
if (beforeEdit != afterEdit && afterEdit != null)
{
e.Node.BackColor = Color.Yellow;
}
}
I guess the node value/text/whatever doesn't get saved until after the AfterLabelEdit routine is finished, but the new value is present in the Node.Label object. Maybe this will help save someone else some time and hassle.
This post has been edited by SpiderSpartan: 27 Feb, 2008 - 12:48 PM