Y
yzhao
I would like to put a treenode into edit mode right after its parent is
expanded, i.e., a user clicks the plus sign of a parent node, after the
expansion, put the first node into edit mode. I called BeginEdit() in
the AfterExpand event handler but the node won't go into edit mode. It
seems EndEdit() gets called right away! If I put BeginEdit() in a
event handler of some other control, say a context menu item, then it
worked. It's weird.
Here is a snapshot of my code:
private void treeView1_AfterExpand(object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
this.treeView1.LabelEdit = true;
TreeNode firstNode = e.Node.FirstNode;
// put the first node into edit mode
if(!firstNode.IsEditing)
{
this.treeView1.SelectedNode = firstNode;
this.treeView1.SelectedNode.BeginEdit();
}
}
private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
this.treeView1.LabelEdit = false;
}
Does anybody has similar problem? Any advice is appreciated.
YZhao
expanded, i.e., a user clicks the plus sign of a parent node, after the
expansion, put the first node into edit mode. I called BeginEdit() in
the AfterExpand event handler but the node won't go into edit mode. It
seems EndEdit() gets called right away! If I put BeginEdit() in a
event handler of some other control, say a context menu item, then it
worked. It's weird.
Here is a snapshot of my code:
private void treeView1_AfterExpand(object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
this.treeView1.LabelEdit = true;
TreeNode firstNode = e.Node.FirstNode;
// put the first node into edit mode
if(!firstNode.IsEditing)
{
this.treeView1.SelectedNode = firstNode;
this.treeView1.SelectedNode.BeginEdit();
}
}
private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
this.treeView1.LabelEdit = false;
}
Does anybody has similar problem? Any advice is appreciated.
YZhao