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 / Design Time / June 2005

Tip: Looking for answers? Try searching our database.

How do I stop the designer from assigning properties to my usercontrols?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 27 May 2005 04:00 GMT
I have some complex (fairly) user controls that I have created.  Some
of those user controls host other user controls.  When I host one of
these on a WinForm, I sometimes run into problems where the designer
blows up with an "Object Reference Not Set to an Instance of an
Object".  Sometimes it even (so kindly) "munches" my code in the
hosting control.  Unfortunately, it seldm if ever tlss "where" exactly
the problem occurred, and to my knowledge there is no way to run the
designer in debug mode and stop through what it's doing.

My fix, for now, as been to put a "if( !DesignMode) test around al of
the set / get fxns in my properties.  This works (usally.... Although
under certain circumstants, the designer has apparently not set the
value of the DesignMode property by the time these properties are
getting configured.)  All this fact-checking in my propertis is
superfluous, were it not for the fact that the designer always wants
to assign values to them that sometimes do not make sense.  Especially
and most particularly when the properties take objects as their
values, and the designer is trying to assign "NULL" to them.

Is there some attribute that I can assign to my properties that will
prevent the designer from trying to retreive values from, or assign
values to them while rendering the control in design mode?  I have
seen the [Borwseable()] attribute, but that doesn't seem to fully
cover it.  Is there a collection of information on these attributes
somewhere that I can read up on?  Surely there has to be a better way
to do this other than what I am currently having to do.

Thanks for any help. :)

JIM

PS - Someone in the newsgroups said that the "IS" in fact a way to run
the designer in debug mode so that I can hunt dorwn problems like this
when they occur.  Does anyone know how to do this or where the article
is on it?  I still really think though that there is a way to keep the
thing from trying to set my properties for me.  Any help is
appreciated.
Bob Powell [MVP] - 27 May 2005 07:32 GMT
>>PS - Someone in the newsgroups said that the "IS" in fact a way to run
the designer in debug mode so that I can hunt dorwn problems like this
when they occur.

You may be referring to the article on debugging controls which can be found
in Windows Forms Tips and Tricks.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

>I have some complex (fairly) user controls that I have created.  Some
> of those user controls host other user controls.  When I host one of
[quoted text clipped - 33 lines]
> thing from trying to set my properties for me.  Any help is
> appreciated.
cody - 08 Jun 2005 21:58 GMT
Simple apply
[DesignerSerialisationVisibility(DesignerSerialisationVisibility.Hidden)] to
the property and the designer will stop to serialize the value of the
property.

>I have some complex (fairly) user controls that I have created.  Some
> of those user controls host other user controls.  When I host one of
[quoted text clipped - 33 lines]
> thing from trying to set my properties for me.  Any help is
> appreciated.

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.