Detect design time in UserControl

by johan.sassner 31. August 2008 13:53
Creating a UserControl for a program, i ran into the problem of detecting whether i was running code in design mode or not. The problem with the DesignMode property from the Component class is that it doesn't work properly in the constructor. I created an overload of the property:
   1:  public new bool DesignMode {
   2:      get {
   3:          return (Process.GetCurrentProcess().ProcessName.Equals("devenv",
   4:  StringComparison.OrdinalIgnoreCase));
   5:      }
   6:  }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

.Net

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.7
Theme by Mads Kristensen

About the author

I've been working with software for a long time now. Started on ABC80 in the early 80's, then Commodore 64/Amiga. Working as a systemdeveloper today with focus on .Net.

Now proud father of Malte

Page List

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar