selected node in TreeView won't get blue

P

PeterB

I have a treeview, and use this code to find the first tagged tree node and
make it the selected tree node. All works fine except for that the blue
square that is used to indicate which node is selected is never shown. What
to do?

private void SelectFirstTaggedTreeNode()
{
if( tView.Nodes.Count != 0 )
{
TreeNode tn;
tn = tView.Nodes[0]; // always use first node
// Get last node in the branch
while( tn.Nodes.Count != 0 )
{
tn = tn.Nodes[0];
}

if( tn.Tag != null )
{
tn.Parent.Expand();
tView.SelectedNode = tn;
}
}
}

regards,

Peter
 
P

PeterB

*blush*

I solved i myself, I forgot to put focus on the treeView itself. Just added:

tView.Focus();

/ Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top