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 / .NET Framework / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Prevent Inherited Property From Persisting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mikesnoise@gmail.com - 03 Nov 2006 04:38 GMT
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-
Mubashir Khan - 03 Nov 2006 11:03 GMT
can you take a look at this...
http://www.codeproject.com/cs/miscctrl/foldertreeview.asp
>I have a control called FolderTreeView that derives from
> System.Windows.Forms.TreeView and automatically populates itself with
[quoted text clipped - 20 lines]
>
> -Mike-
Peter Thornqvist - 03 Nov 2006 23:45 GMT
Can't you just redeclare the Nodes property like this:

private class FolderTreeView : System.Windows.Forms.TreeView
{
 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 public System.Windows.Forms.TreeNodeCollection Nodes;
}

Signature

Regards, Peter


Rate this thread:







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.