Highlighting a default treeview node
-
How do you highlight a treeview node at startup? I have the node needed from BuildNodeTree() as defaultNode, and the following in frmMain_Load
private void frmMain_Load(object sender, EventArgs e)
{
BuildNodeTree();
treeview.SelectedNode = defaultNode;
}This doesn't highlight the node. I'm assuming because it hasn't displayed yet. What are my options? Thank you.
-
How do you highlight a treeview node at startup? I have the node needed from BuildNodeTree() as defaultNode, and the following in frmMain_Load
private void frmMain_Load(object sender, EventArgs e)
{
BuildNodeTree();
treeview.SelectedNode = defaultNode;
}This doesn't highlight the node. I'm assuming because it hasn't displayed yet. What are my options? Thank you.
Nope. Having
treeview.SelectedNode = treeview.Nodes[0];
inside a Form_Load() handler is sufficient provided the TreeView has focus. A lot of Windows Controls don't mark their selections when they don't have focus. One way of getting there automatically is by making sure treeview.TabStop is true (default) and TabIndex is zero. :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Nope. Having
treeview.SelectedNode = treeview.Nodes[0];
inside a Form_Load() handler is sufficient provided the TreeView has focus. A lot of Windows Controls don't mark their selections when they don't have focus. One way of getting there automatically is by making sure treeview.TabStop is true (default) and TabIndex is zero. :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
How do you highlight a treeview node at startup? I have the node needed from BuildNodeTree() as defaultNode, and the following in frmMain_Load
private void frmMain_Load(object sender, EventArgs e)
{
BuildNodeTree();
treeview.SelectedNode = defaultNode;
}This doesn't highlight the node. I'm assuming because it hasn't displayed yet. What are my options? Thank you.
Selecting node is highlighted by default. you can note that by change the background of the form.
-
Nope. Having
treeview.SelectedNode = treeview.Nodes[0];
inside a Form_Load() handler is sufficient provided the TreeView has focus. A lot of Windows Controls don't mark their selections when they don't have focus. One way of getting there automatically is by making sure treeview.TabStop is true (default) and TabIndex is zero. :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Setting
HideSelection
tofalse
highlights the selection (although dimmed) even when the control does not have focus. Most windows controls have aHideSelection
property.:thumbsup:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages