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 2004

Tip: Looking for answers? Try searching our database.

How to determine if currently in design mode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marina - 07 Jun 2004 21:18 GMT
The problem is that DesignMode property only returns True, if the control
can be directly modified.

If the control is on a user control, and that user control is on a form -
the design mode property of the original control is now False.

This isn't useful, because what I need to know is if the form in in the
VS.NET designer - i.e. it is not an actual executable that is currently
running.

Is there any way to get this information, since DesignMode property is kind
of inaccurate?
Andrew Smith \(Infragistics\) - 08 Jun 2004 00:43 GMT
Technically, that property returns the state of that component/control. In
the case of controls on a usercontrol they are in runmode since there is no
designer/site associated with the controls. If you really need to know if
any control in the parent chain is in design mode, you can walk up the
parent chain, checking to see if the Site is non-null and if so, checking
the designmode property of the site.
e.g.
 public static bool IsDesignMode(Control control)
 {
  if (control == null)
   return false;

  if (control.Site != null && control.Site.DesignMode)
   return true;

  return IsDesignMode(control.Parent);
 }

> The problem is that DesignMode property only returns True, if the control
> can be directly modified.
[quoted text clipped - 8 lines]
> Is there any way to get this information, since DesignMode property is kind
> of inaccurate?
Marina - 11 Jun 2004 15:50 GMT
Ok, thanks, I might try that.

It's too bad there is no general property that just tells the developer if
the application is currently being work on in the IDE, or if it is actually
running.  That seems a lot more useful then to know if the current component
can be designed.

Thanks.

"Andrew Smith (Infragistics)" <productmanager@infragistics.com> wrote in
message news:ey18ykOTEHA.1508@TK2MSFTNGP11.phx.gbl...
> Technically, that property returns the state of that component/control. In
> the case of controls on a usercontrol they are in runmode since there is no
[quoted text clipped - 27 lines]
> kind
> > of inaccurate?
Grant Frisken - 13 Jun 2004 07:52 GMT
You can do this by checking the value of
Reflection.Assembly.GetEntryAssembly.  If this is null then you are most
likely running from the IDE.   This is a bit of a hack and assumes your
runtime entry executable is a managed assembly - but it will probably
achieve what you want.

Regards
Grant

> Ok, thanks, I might try that.
>
[quoted text clipped - 41 lines]
> > kind
> > > of inaccurate?

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.