PC Review


Reply
Thread Tools Rate Thread

the best way to remember all of a TreeView's node's collapsed stat

 
 
=?Utf-8?B?a2V2aW4=?=
Guest
Posts: n/a
 
      22nd Mar 2005
I would like to remember the state of the nodes after the treeview gets
disposed, but not necessarily after the app terminates so I don't need a disk
file. I was thinking about using the tag property, but I am already using it,
so then I though about making a custom treeiew using inheritance and adding
another tag type property? Any clues?
kevin
 
Reply With Quote
 
 
 
 
Mitchell S. Honnert
Guest
Posts: n/a
 
      22nd Mar 2005
"kevin" <(E-Mail Removed)> wrote in message
news:2C7C46C1-F86E-4785-A710-(E-Mail Removed)...
>I would like to remember the state of the nodes after the treeview gets
> disposed, but not necessarily after the app terminates so I don't need a
> disk
> file. I was thinking about using the tag property, but I am already using
> it,
> so then I though about making a custom treeiew using inheritance and
> adding
> another tag type property? Any clues?
> kevin

So, what you are looking for is something that can reside in memory that can
store a treeview-like structure along with the collapsed stated of each
node? If so, why not just use the actual TreeView object itself? You
mention the TreeView getting disposed, but if you want to "remember" the
node hierarchy and the collapsed states, why not just copy the instance of
the TreeView in question to a variable that can be accessed by whatever
component which needs to do the "remembering"? You'd not only have the
entire hierarchy and the collapsed states, but *all* of the original
properties that you'd previously set, including your custom Tag values.

- Mitchell S. Honnert

PS: Here's some unsolicited advice. :-) Personally, I avoid using the Tag
property as all costs. You mention extending the TreeView node class using
inheritence and this is exactly what I would do (and have done) when I need
to add a custom property to a node. I don't know if you have other people
which might have to maintain your code, but *you* may know that the Tag
property is (for example) used to store a single character code which
represents the type of node, but someone else wouldn't know just by looking
at the value. But if you extended the TreeView node and added your own
custom, enumerated NodeType property, there'd be no doubt about the purpose
of the property.


 
Reply With Quote
 
Kevin
Guest
Posts: n/a
 
      22nd Mar 2005
Mitchell S. Honnert wrote:
> "kevin" <(E-Mail Removed)> wrote in message
> news:2C7C46C1-F86E-4785-A710-(E-Mail Removed)...
>
>>I would like to remember the state of the nodes after the treeview gets
>>disposed, but not necessarily after the app terminates so I don't need a
>>disk
>>file. I was thinking about using the tag property, but I am already using
>>it,
>>so then I though about making a custom treeiew using inheritance and
>>adding
>>another tag type property? Any clues?
>>kevin

>
> So, what you are looking for is something that can reside in memory that can
> store a treeview-like structure along with the collapsed stated of each
> node? If so, why not just use the actual TreeView object itself? You
> mention the TreeView getting disposed, but if you want to "remember" the
> node hierarchy and the collapsed states, why not just copy the instance of
> the TreeView in question to a variable that can be accessed by whatever
> component which needs to do the "remembering"? You'd not only have the
> entire hierarchy and the collapsed states, but *all* of the original
> properties that you'd previously set, including your custom Tag values.
>
> - Mitchell S. Honnert
>
> PS: Here's some unsolicited advice. :-) Personally, I avoid using the Tag
> property as all costs. You mention extending the TreeView node class using
> inheritence and this is exactly what I would do (and have done) when I need
> to add a custom property to a node. I don't know if you have other people
> which might have to maintain your code, but *you* may know that the Tag
> property is (for example) used to store a single character code which
> represents the type of node, but someone else wouldn't know just by looking
> at the value. But if you extended the TreeView node and added your own
> custom, enumerated NodeType property, there'd be no doubt about the purpose
> of the property.
>
>

thanks Mitchell,
I would agree that using the tag property can be confusing, but if it is
used consistently throughout the code and is well documented I don't
really see a problem (it may even be easier than creating a custom
control for just a single addition property) However by iheriting the
treeview class, it become easy to add whatever custom properties are
needed, then using the tag property becomes a hassle.
thanks for your input
kevin
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expand any node then other node collaps using JS - Treeview Contro Manoj Microsoft ASP .NET 0 4th Nov 2008 01:35 PM
Treeview : Adding a node to a specific existing node with Net 1.0(work with 2.0) michelqa@yahoo.ca Microsoft C# .NET 2 12th Jun 2008 08:18 AM
How to find node in TreeView by using string(the same as Node.Text) ? jiing Microsoft ASP .NET 0 27th Apr 2007 03:34 AM
Context menu popup on treeview node returning wrong selected node Claire Microsoft C# .NET 2 5th Mar 2007 11:59 AM
How can I determine the node number of a node in my treeview meh Microsoft VB .NET 2 4th Sep 2003 04:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 AM.