DesignMode with Controls

Posted by John Dyer on Stack Overflow See other posts from Stack Overflow or by John Dyer
Published on 2008-08-29T16:37:10Z Indexed on 2010/04/22 18:23 UTC
Read the original article Hit count: 290

Filed under:
|

Has anyone found a useful solution to the DesignMode problem when developing controls?

The issue is that if you nest controls then DesignMode only works for the first level. The second and lower levels DesignMode will always return FALSE.

The standard hack has been to look at the name of the process that is running and if it is "DevEnv.EXE" then it must be studio thus DesignMode is really TRUE.

The problem with that is looking for the ProcessName works its way around through the registry and other strange parts with the end result that the user might not have the required rights to see the process name. In addition this strange route is very slow. So we have had to pile additional hacks to use a singleton and if an error is thrown when asking for the process name then assume that DesignMode is FALSE.

A nice clean way to determine DesignMode is in order. Acually getting Microsoft to fix it internally to the framework would be even better!

© Stack Overflow or respective owner

Related posts about .NET

Related posts about usercontrols