Groups | Blog | Home
all groups > dotnet windows forms > april 2007 >

dotnet windows forms : SelectedNode


gmb
4/21/2007 12:00:00 AM
Hi everyone again,

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

Thanks in advance,
gmb

Herfried K. Wagner [MVP]
4/21/2007 1:09:30 PM
"gmb" <diehard_gmb@wp.pl> schrieb:
[quoted text, click to view]

'Me.TreeView1.SelectedNode.Nodes(<index>)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
gmb
4/21/2007 2:30:13 PM
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


[quoted text, click to view]
Herfried K. Wagner [MVP]
4/21/2007 8:42:41 PM
"gmb" <diehard_gmb@wp.pl> schrieb:
[quoted text, click to view]

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
gmb
4/22/2007 4:54:54 PM
Ty very, very much

gmb

[quoted text, click to view]
AddThis Social Bookmark Button