Re: Control.DesignMode issues.

Charlotte Foust <[email protected]> Thu, 13 Dec 2007 16:32:30 -0800
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <F55048AF7E974F429BB24597D7355EEA704184@INFOSERVER04.infostat.local>
I've seen it frequently.  It seems to kick in when the usercontrol is
embedded in another uc.  In VB.Net, you can use this:

if System.Diagnostics.Process.GetCurrentProcess().ProcessName = "devenv"
then exit sub

Charlotte Foust  

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:[email protected]] On Behalf Of
Mike Andrews
Sent: Thursday, December 13, 2007 5:58 AM
To: [email protected]
Subject: [DOTNET-WINFORMS] Control.DesignMode issues.

I'm having a particular issue with designing controls that I'm guessing
I either didn't understand properly or there's something else going on.
The current project on which I'm working has numerous usercontrols.
Some of these usercontrols contain other composite usercontrols.
Additionally, some of these controls derive their data from a database
automatically.  Now, in order to design these controls, the
Control.DesignMode property was used to prevent code from executing when
designing the control.
The problem I'm having now is that when I draw one of those controls on
the design surface of another usercontrol that DesignMode property is
returning false for the drawn control even though I'm currently in
design mode for the control I'm currently building.

 I thought (or assumed) that the Control.DesignMode chained down through
the various child controls so that each control would know that its
parent or its parent's parent was in design mode.  Apparently I was
mistaken.

Has anyone else experienced this or know what's going on here or any
suggestions on how to overcome this one?

Thanks,
Mike