Windows Develop Bookmark and Share   
 index > Windows Forms General > Problem with TreeView refreshing
 

Problem with TreeView refreshing

Hi,
I have treeView1 in tre form. I create another TreeView (treeView2)in memory and I would like to do something like :
treeView1=treeView2;
Is it possible?
Regards.
Leszek
leszekt  Thursday, September 17, 2009 2:27 PM
That doesn't work, TreeView is a reference type. After that assignment, treeView1 will just be referencing treeView2 and any changes you make to treeView1 will be visible on the screen.

Not sure what you are really trying to do, it doesn't make sense to keep a copy of a TreeView in memory. Maybe keep a copy of the nodes. That's hard too, TreeNodeCollection doesn't have a Clone() method. It's CopyTo() method is a weak alternative.

Hans Passant.
nobugz  Thursday, September 17, 2009 4:03 PM
That doesn't work, TreeView is a reference type. After that assignment, treeView1 will just be referencing treeView2 and any changes you make to treeView1 will be visible on the screen.

Not sure what you are really trying to do, it doesn't make sense to keep a copy of a TreeView in memory. Maybe keep a copy of the nodes. That's hard too, TreeNodeCollection doesn't have a Clone() method. It's CopyTo() method is a weak alternative.

Hans Passant.
nobugz  Thursday, September 17, 2009 4:03 PM
Thanks Hans.
leszekt  Friday, September 18, 2009 11:17 AM

You can use google to search for other answers

Custom Search

More Threads

• how to get a textbox to host a background image?
• Why is this drawing slower
• WebBrowser ShowPrintPreviewDialog only the second time
• GDI+ Flickering (animation)
• Capturing Video Stream
• Bug removing rows from a custom class datagridview data source?
• Windows Forms
• Disable items in CheckedListBox
• SetProcessWorkingSetSize or Process.MaxWorkingSet
• ShellExtension -> keyboard event