Re: Control.DesignMode issues.

"Eames, Andrew" <[email protected]> Thu, 13 Dec 2007 09:45:43 -0500
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
Use this instead of Control.DesignMode 

    public static bool DesignMode
    {
      get
      {
        return
Application.ExecutablePath.ToLower(CultureInfo.InvariantCulture).IndexOf
("devenv.exe") > -1;
      }
    }

Andrew

-----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 8: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


-- 
BEGIN-ANTISPAM-VOTING-LINKS
------------------------------------------------------

NOTE: This message was trained as non-spam.  If this is wrong,
please correct the training as soon as possible.

Teach CanIt if this mail (ID 10369465) is spam:
Spam:
http://mail-gw.cognex.com/canit/b.php?c=s&i=10369465&m=3f976b8e1a55
Not spam:
http://mail-gw.cognex.com/canit/b.php?c=n&i=10369465&m=3f976b8e1a55
Forget vote:
http://mail-gw.cognex.com/canit/b.php?c=f&i=10369465&m=3f976b8e1a55
------------------------------------------------------
END-ANTISPAM-VOTING-LINKS