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 / September 2005

Tip: Looking for answers? Try searching our database.

TreeNode collapse method does not persist the state of the sub-nodes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
amidanr@gmail.com - 14 Sep 2005 16:36 GMT
Hi all,

I haven't been able to find any post regarding this problem...
the MSDN help about TreeNode.Collapse clearly says:

"The state of a TreeNode is persisted. For example, if the next level
of child nodes was not collapsed previously, when the Expand method is
called, the child nodes appear in their previously expanded state."

but what actually happens, is that all the sub node are collapsed as
well...is that the normal behaviour? how can I persist their state?

Thanks,
Amidan.
Tom Dacon - 14 Sep 2005 16:58 GMT
This works just like the documentation for me, on vs2003, with framework
1.1.4322 SP1.

I'd check to see if you have any code in the treeview's BeforeCollapse,
BeforeExpand, AfterCollapse, or AfterExpand event handlers that might be
affecting what's going on.

HTH,
Tom Dacon
Dacon Software Consulting

> Hi all,
>
[quoted text clipped - 10 lines]
> Thanks,
> Amidan.
Claes Bergefall - 15 Sep 2005 08:27 GMT
It's a bug (or a documentation error):

http://groups.google.se/group/microsoft.public.dotnet.framework.windowsforms.con
trols/browse_thread/thread/ec14b36a753a0fd9/41a1d812df4d8c27?lnk=st&q=treeview+c
ollapse+author:Claes+author:Bergefall&rnum=1&hl=sv#41a1d812df4d8c27


   /claes

> Hi all,
>
[quoted text clipped - 10 lines]
> Thanks,
> Amidan.
Claes Bergefall - 15 Sep 2005 08:38 GMT
To have it work according to the docs you'll need to use
P/Invoke and send a TVM_EXPAND message to it
That will persist the state of the subnodes

Public Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As
IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As
IntPtr) As Integer
Public Const TV_FIRST As Integer = &H1100
Public Const TVM_EXPAND As Integer = TV_FIRST + 2
Public Const TVE_COLLAPSE As Integer = &H1
Public Const TVE_EXPAND As Integer = &H2
Public Const TVE_TOGGLE As Integer = &H3

....
SendMessage(myTreeView.Handle, TVM_EXPAND, TVE_COLLAPSE, myTreeNode.Handle)

     /claes

> It's a bug (or a documentation error):
>
[quoted text clipped - 16 lines]
>> Thanks,
>> Amidan.
amidanr@gmail.com - 15 Sep 2005 10:04 GMT
Claes,
thank you very much, that solved the problem (though had to translate
it to C#). searched for hours for this kind of solution...

cheers,
Amidan.

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.