|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Prevent Inherited Property From PersistingSystem.Windows.Forms.TreeView and automatically populates itself with TreeNodes representing the Windows file system. Here's the behavior I'm seeing: 1) Add the FolderTreeView control to my Form in the designer. 2) Modify the FolderTreeView.cs file. 3) Rebuild and go back to the Form designer that is hosting the control from step 1. The result is another root "Desktop" node has been added to the control so I end up with duplicated entries. My theory is that the Nodes property from the base TreeView class is being persisted with the form. Then, the FolderTreeView's constructor runs which calls Nodes.Clear() and then populates the control with top level FileSystem objects. Next, the old nodes from before the rebuild are added back to the TreeView control which results in duplicates. My best guess at fixing this is to somehow prevent the designer from persisting the Nodes property of the FolderTreeView control. But since this property is inherited from TreeView I'm not sure how to change the way it is persisted. Please help! -Mike- can you take a look at this...
http://www.codeproject.com/cs/miscctrl/foldertreeview.asp <mikesno***@gmail.com> wrote in message Show quote news:1162525116.845329.177580@m73g2000cwd.googlegroups.com... >I have a control called FolderTreeView that derives from > System.Windows.Forms.TreeView and automatically populates itself with > TreeNodes representing the Windows file system. Here's the behavior I'm > seeing: > > 1) Add the FolderTreeView control to my Form in the designer. > 2) Modify the FolderTreeView.cs file. > 3) Rebuild and go back to the Form designer that is hosting the control > from step 1. > > The result is another root "Desktop" node has been added to the control > so I end up with duplicated entries. My theory is that the Nodes > property from the base TreeView class is being persisted with the form. > Then, the FolderTreeView's constructor runs which calls Nodes.Clear() > and then populates the control with top level FileSystem objects. Next, > the old nodes from before the rebuild are added back to the TreeView > control which results in duplicates. > > My best guess at fixing this is to somehow prevent the designer from > persisting the Nodes property of the FolderTreeView control. But since > this property is inherited from TreeView I'm not sure how to change the > way it is persisted. Please help! > > -Mike- > |
|||||||||||||||||||||||