|
1金钱
功能流程是这样的:对treeview节点重命名,在节点上点击右键弹出菜单,点击重命名,执行(如图)。问题来了,重命名能成功,但是之后会自动执行afterselect事件,然后又执行AfterLabelEdit事件,这是怎么一回事,该怎么解决!
我写的的AfterLabelEdit的代码如下:
private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
newValue = e.Label;
string[] distinctCatalog_rodeDevice = GetCatalogFromDataTable(dt1_CreateAllSymbol);
if(distinctCatalog_rodeDevice.Contains(oldValue))
{
level_change = 1;
}
else if(distinctSym_judgeDt.Contains(oldValue)||distinctSym_dgv1.Contains(oldValue))
{
level_change = 2;
}
else if(oldValue=="符号")
{
level_change = 0;
}
switch(level_change)
{
case 0:
MessageBox.Show("根节点不能重命名!");
break;
case 1:
RenameTreeNode();
//e.Node.EndEdit(true);
//e.CancelEdit = true;
break;
case 2:
RenameTreeNode();
break;
default:
MessageBox.Show("该节点不能重命名!");
break;
}
}
|
-
树结构
-
执行
|