How to make a TreeView node editable on double click (C#)

The first thing we need to do (usually via the designer) is to set the LabelEdit property of the TreeView to true. Then we go to the handler method of the NodeMouseDoubleClick event and write as follows:

private void treeListe_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node == null)
return; //this is just to be on the safe side
//normally e.Node is the node where we double clicked and cannot be null

e.Node.BeginEdit();

}

No comments: