selected node in TreeView won't get blue

  • Thread starter Thread starter PeterB
  • Start date Start date
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
 
*blush*

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

tView.Focus();

/ Peter
 
Back
Top