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 / October 2004

Tip: Looking for answers? Try searching our database.

Treeview (Setting the selected cell in code)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred Herring - 25 Oct 2004 20:41 GMT
I use large treeviews in my application.  I have trouble getting back to
where I was working when I repaint my tree.  How can I in code, flag the node
I was working on before the repaint and have that node come up as being
selected after the repaint?

Thanks,
Fred Herring
Sijin Joseph - 26 Oct 2004 05:05 GMT
If you are not changing the nodes in the treeview then you can store a
reference to the SelectedNode and then set that node as selected after
the repaint

TreeNode selNode = treeView.SelectedNode;
//Paint
treeView.SelectedNode = selNode

But if you are changing the nodes then you have to store some
information about the node that will help you identify the node after
creation. Maybe you can use the Tag property or the FullPath property to
identify the TreeNode after is is created again.

Let me know if you have nay doubts.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> I use large treeviews in my application.  I have trouble getting back to
> where I was working when I repaint my tree.  How can I in code, flag the node
[quoted text clipped - 3 lines]
> Thanks,
> Fred Herring
Fred Herring - 26 Oct 2004 16:17 GMT
Thanks for the reply.  I came to the same conclusion about saving the full
path of each node since I destroy the old tree when I repaint it.  As I
repaint the new tree from the datatable containing the data, I store the full
path of each node that is created and added.  Having come this far, I am now
embarassed to say, I don't know how to use the fullpath data to select a
cell.  Can you show me how to select a cell programatically if you know its
full path.  

Microsoft should consider giving iq tests to users before granting them msdn
subscriptions.  Might screen out dumb questions like mine.

Thanks,
Fred

> If you are not changing the nodes in the treeview then you can store a
> reference to the SelectedNode and then set that node as selected after
[quoted text clipped - 22 lines]
> > Thanks,
> > Fred Herring

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.