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 / June 2007

Tip: Looking for answers? Try searching our database.

Treeview Index problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B. Chernick - 28 Jun 2007 15:56 GMT
I'm trying to program a form with a treeview.   I have just created a root
node in the control.  Now I have called a routine to create a child node. As
I create these nodes I want to keep track of their indices in a data
structure.  The code is roughly as follows:

(Assume the original root node is the selected node)

Dim tn As New TreeNode
tvAreas.SelectedNode.Nodes.Add(tn)
tvAreas.SelectedNode = tn

At this point I try to get the index of the selected node and it's always -1

I've tried both
i = tvAreas.SelectedNode.Index
and
i = tvAreas.Nodes.IndexOf(tvAreas.SelectedNode)

What's going on here?
B. Chernick - 28 Jun 2007 17:14 GMT
My apologies, ignore the previous append.  I was under the impression that
there was a master index for all nodes in a treeview, not just relative
indices for each node.  (Of course, if this assumption is also wrong, please
feel free to correct me.)

> I'm trying to program a form with a treeview.   I have just created a root
> node in the control.  Now I have called a routine to create a child node. As
[quoted text clipped - 15 lines]
>
> What's going on here?

Rate this thread:







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.