Hi,
I have a TabControl with 2 TabPages (TabPage1 and TabPage2).
I have a TreeView control with 2 nodes (Page1 and Page2).
When i click on Page1 node, I want to display the TabPage1...the same
thing for Page2 node (TabPage2).
This is easy to do using selectedIndex = ...
But i would like to do it in another way.
Evertime that i select a node in my TreeView, i generate a AfterSelect
event. This event as an argument which is e. This argument can be used
to determine the value of selected node by using e.Node.Text.
and here starts my question. I would like to do something like that :
-----------------------
Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
TCPreferences.SelectedTab = CType("Tab" & e.Node.Text, TabPage)
End Sub
-----------------------
I know that i can not cast it like that...but I would like to keep this
"direction"...how can i do ?
Thx,
Maileen
Herfried K. Wagner [MVP] - 31 Oct 2004 18:01 GMT
"Maileen" <nospan@email.com> schrieb:
> I have a TabControl with 2 TabPages (TabPage1 and TabPage2).
> I have a TreeView control with 2 nodes (Page1 and Page2).
[quoted text clipped - 15 lines]
>
> TCPreferences.SelectedTab = CType("Tab" & e.Node.Text, TabPage)
Add a reference to the tab associated with a certain node to its 'Tag'
property:
\\\
Dim n As TreeNode = ...
n.Tag = Me.TabPage1
...
///
In the 'AfterSelect' event handler, you can use this code to select the
associated tab:
\\\
Me.TabControl1.SelectedTab = DirectCast(e.Node.Tag, TabPage)
///

Signature
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/