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 / Windows Forms / WinForm General / April 2006

Tip: Looking for answers? Try searching our database.

Newbie with Treeview Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oh-its-all-gone-wrong - 13 Apr 2006 15:06 GMT
Hi All,
I have a TreeView setup with 2 Items on it. Node1, Node2. I would Like to be
able to open a form called Form1, when I double click on Node1, Form 2 when
I double click on Node 2. I`ve done a google search but can`t find to much
info on it.

Could somebody possible point me in the right direction with a bit of code
or link please?

Many Thanks

Si
Claes Bergefall - 13 Apr 2006 15:26 GMT
This is easy if you're using VS 2005 (.NET 2.0)
Add an event handler for the the TreeView.NodeMouseDoubleClick event and
create/show your forms in there

   /claes

> Hi All,
> I have a TreeView setup with 2 Items on it. Node1, Node2. I would Like to
[quoted text clipped - 8 lines]
>
> Si
Cerebrus - 14 Apr 2006 05:52 GMT
In VS  2003, you could trap the DoubleClick event :

Private Sub TreeView1_DoubleClick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TreeView1.DoubleClick
 Dim selNode as TreeNode = TreeView1.SelectedNode
 If Not selNode is Nothing Then
 If selNode.Text = "Node 1" Then
   'Open Form 1
   Dim frm as new Form1()
   frm.Show()
 Else
   'Open Form 2
   Dim frm as new Form2()
   frm.Show()
 End if
 End if
End Sub

HTH,

Regards,

Cerebrus.
Susan H - 18 Apr 2006 18:08 GMT
Also, if you want to dynamically load forms, you can do this using
reflection.  It's not as hard as it sounds, and I can provide asimple code
sample if you're interested.

This is as opposed to having a case statement for every node (which works
absolutely just fine).  I'm talking for example if you want one function that
will open the appropriate form no matter how many nodes you add, without
adding more case statements.

Good luck.

> Hi All,
> I have a TreeView setup with 2 Items on it. Node1, Node2. I would Like to be
[quoted text clipped - 8 lines]
>
> Si

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.