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

Tip: Looking for answers? Try searching our database.

Thsi isnt working:   If Me.DesignMode = True Then Return

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moondaddy - 10 Feb 2005 16:30 GMT
I have a user control (uc2)which lives on another user control (uc1) on a
form (a nested user control).  When I open the form in design view the the
load even fires in uc2 so the first line of code in the in its load event
is:

If Me.DesignMode = True Then Return

However, it doesnt work and code is still executing after this line.  The
last line of code in the load event calls a private method which loads data
into a grid.  This is the only place this private method gets called and
every time I open the form in design view I get a series of error beeps and
then I see data has loaded into the grid.

Any good advise on how to stop code from executing in design view?

Thanks.

Signature

moondaddy@nospam.com

Matt Garven - 11 Feb 2005 00:13 GMT
The behaviour you're seeing is because the top level control (your form) and
the controls on it are in design mode, the other user control (uc2) is just
part of the implementation of the designing user control (uc1). Notice how
you can't select  uc2 when you're designing the form?

In uc2, you can check the Parent.DesignMode (it's protected, you'll need to
add a property to expose it). We have an interface which all our controls
implement to allow controls to check their parent's DesignMode
polymorphically.

If you wanted to get it going quickly, you can also use the value of
Application.ExecutablePath.ToLower().IndexOf("devenv.exe") > -1. You might
want to cache this value, it may have an impact on performance if it's called
frequently.

Hope this helps.

Regards,
Matt Garven

> I have a user control (uc2)which lives on another user control (uc1) on a
> form (a nested user control).  When I open the form in design view the the
[quoted text clipped - 12 lines]
>
> Thanks.

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.