What is "Friend entries"?
Control.DesignMode issues.
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > .Net Development > Control.DesignMode issues. 14 December 2007 01:45:49

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Control.DesignMode issues.

Mike Andrews 14 December 2007 01:45:49
 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

Add comment
Andrew Eames 13 December 2007 17:45:43 permanent link ]
 Use this instead of Control.DesignMode

public static bool DesignMode
{
get
{
return
Application.Executa­blePath.ToLower(Cult­ureInfo.InvariantCul­ture).IndexOf
("devenv.exe") > -1;
}
}

Andrew

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:D­OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of
Mike Andrews
Sent: Thursday, December 13, 2007 8:58 AM
To: DOTNET-WINFORMS@DIS­CUSS.DEVELOP.COM
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-VOTI­NG-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.cogn­ex.com/canit/b.php?c­=s&i=10369465&m=3f97­6b8e1a55
Not spam:
http://mail-gw.cogn­ex.com/canit/b.php?c­=n&i=10369465&m=3f97­6b8e1a55
Forget vote:
http://mail-gw.cogn­ex.com/canit/b.php?c­=f&i=10369465&m=3f97­6b8e1a55
-------------------­--------------------­---------------
END-ANTISPAM-VOTING­-LINKS

Add comment
Andy Langowitz 14 December 2007 01:11:23 permanent link ]
 I, like you have been surprised in the past by DesignMode returning false
even in design mode. My recollection is that DesignMode does not return
true until after a certain stage of the Control's life cycle. In
particular, DesignMode always returns false in the constructor, and it may
even still be false in the Load event (I may be wrong about that).

Warning: I last dealt with this in .NET 1.1, so I don't know if it has
changed in .NET 2.0, let alone .NET 3.

Add comment
Mike Andrews 14 December 2007 01:28:57 permanent link ]
 I'm using it in Framework 2.0 so it's no different.

On Dec 13, 2007 4:11 PM, Andy Langowitz <andy@langowitz.com­> wrote:

I, like you have been surprised in the past by DesignMode returning false
even in design mode. My recollection is that DesignMode does not return
true until after a certain stage of the Control's life cycle. In
particular, DesignMode always returns false in the constructor, and it may
even still be false in the Load event (I may be wrong about that).
Warning: I last dealt with this in .NET 1.1, so I don't know if it has
changed in .NET 2.0, let alone .NET 3.

Add comment
Charlotte Foust 14 December 2007 01:45:49 permanent link ]
 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.GetCurrentPr­ocess().ProcessName = "devenv"
then exit sub

Charlotte Foust

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:D­OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of
Mike Andrews
Sent: Thursday, December 13, 2007 5:58 AM
To: DOTNET-WINFORMS@DIS­CUSS.DEVELOP.COM
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

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > .Net Development > Control.DesignMode issues. 14 December 2007 01:45:49

see also:
fopen a URL with = in it
[PHP] Reading with C 'struct' data
Parsing question from newbie
пройди тесты:
see also:
Cyber Data Recorder Client/Server V1.5
Network Monitor Sniffer V2.0
C++ Programming

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .