Hi all,
I have an MDI parent form which has a Treeview control directly on it, docked left. The remaining space will have MDI child forms.
When I (at runtime) add a node to the Treeview, I want the user to be able to edit the textlabel of the node immediately without interaction. The code I have so far:
As you can see, I search the newest node by it's Key, make it the selected node, ensure it's visible and begin editing the label. So far so good, this works perfectly.
BUT, when I start typing to assign a new name to the node, it accepts one character and then gives the focus to the last active MDI child.
If there are no MDI children then it works fine.
I've tried calling .Focus() on the treeview before .BeginEdit() but no luck.
Does anyone have an idea why this happens? Or better yet, how to make it work correctly?
Regards, Ruffnekk
---
Is it true that cannibals don't eat clowns because they taste funny?
I have an MDI parent form which has a Treeview control directly on it, docked left. The remaining space will have MDI child forms.
When I (at runtime) add a node to the Treeview, I want the user to be able to edit the textlabel of the node immediately without interaction. The code I have so far:
Code:
private void SelectAndEditNode(string id)
{
TreeNode[] temp = tvwProjects.Nodes.Find(id, true);
if (temp != null && temp.Length > 0)
{
tvwProjects.SelectedNode = temp[0];
tvwProjects.SelectedNode.EnsureVisible();
tvwProjects.SelectedNode.BeginEdit();
}
}
As you can see, I search the newest node by it's Key, make it the selected node, ensure it's visible and begin editing the label. So far so good, this works perfectly.
BUT, when I start typing to assign a new name to the node, it accepts one character and then gives the focus to the last active MDI child.
If there are no MDI children then it works fine.
I've tried calling .Focus() on the treeview before .BeginEdit() but no luck.
Does anyone have an idea why this happens? Or better yet, how to make it work correctly?
Regards, Ruffnekk
---
Is it true that cannibals don't eat clowns because they taste funny?