Treeview: inactive control to active control changes selected treenode

  • Thread starter Thread starter Robert Linder
  • Start date Start date
R

Robert Linder

Hello,

When I make the treeview the active control on the form the first
node is selected when there is no active node.

I am unable to find a way to prevent the control from selecting the
first node.

Does anyone have a basic example to prevent the first node from
being selected when there is no active node selected upon the control
begin made active.


Robert
 
Hi Robert,

There probably a much more elegant way of doing this but one thing you
could do is declare a private variable in your form and update it when
you select a node in the treeview. (for example int selectedIndex =
null;)

Presuming your using

treeView1.Select();

to make the control active follow that with

treeView1.SelectedNode = selectedIndex;

Of course if you never update the private variable selectedIndex will
be null (hence no node selected).

Simon
 
Back
Top