//设置TreeView属性值LabelEdit为true
this.TreeView.LabelEdit = true;
//双击节点,选中节点变为可编辑状态
private void TreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.TreeView.SelectedNode.BeginEdit();
}
//添加窗口KeyDown事件
//按F2,选中节点变为可编辑状态
private void TestGui_KeyDown(object sender, KeyEventArgs e)
{
if (this.TreeView.SelectedNode != null && e.KeyCode == Keys.F2)
{
this.TreeView.SelectedNode.BeginEdit();
}
}