Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

a cast beginner question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maileen - 31 Oct 2004 17:37 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.