SelectedNode

  • Thread starter Thread starter gmb
  • Start date Start date
G

gmb

Hi everyone again,

How to check SelectedNode's child? There is ->SelectedNode->Parent, but how
to check/control a child?

Thanks in advance,
gmb
 
gmb said:
How to check SelectedNode's child? There is ->SelectedNode->Parent, but
how to check/control a child?

'Me.TreeView1.SelectedNode.Nodes(<index>)'.
 
Ty for Your reply,

I would like to control a node only if it has a child node.

if (TreeView1->SelectedNode->Nodes[0])
{
//mycode
}

Given code works (enters parenthesis) only if a node has child nodes, but if
there is no TreeView1->SelectedNode->Nodes[0] it returns an exception of
type System.ArgumentOutOfRangeException.
Could You tell me what should be taken into considerations? I really don't
want to handle this exception.

gmb
 
gmb said:
I would like to control a node only if it has a child node.

if (TreeView1->SelectedNode->Nodes[0])
{
//mycode
}

Given code works (enters parenthesis) only if a node has child nodes, but
if there is no TreeView1->SelectedNode->Nodes[0] it returns an exception
of type System.ArgumentOutOfRangeException.

\\\
if (TreeView1->SelectedNode->Nodes->Count > 0)
...;
///
 
Ty very, very much

gmb

Herfried K. Wagner said:
gmb said:
I would like to control a node only if it has a child node.

if (TreeView1->SelectedNode->Nodes[0])
{
//mycode
}

Given code works (enters parenthesis) only if a node has child nodes, but
if there is no TreeView1->SelectedNode->Nodes[0] it returns an exception
of type System.ArgumentOutOfRangeException.

\\\
if (TreeView1->SelectedNode->Nodes->Count > 0)
...;
///
 
Back
Top