Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Best way to determine DesignTime??

0 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Jeffrey Huntsman

ungelesen,
06.11.2003, 20:38:1806.11.03
an
I have several controls that are being used in a Windows Forms application.
Some of the controls perform tasks (e.g. reading from a resource file) that
can only be accomplished at runtime.

I tried placing the runtime only code in an if like this:
if(!this.DesignTime)
{
blah
}

I am experiencing weirdness in the designer, especially in inherited forms
that it appears the DesignTime property is returning false when it should
return true. OK, so that partially makes sense because the control is being
instantiated by the designer, but the problem is that my control is causing
nasty exceptions to be thrown and the designer likes to shutoff the
properties window when this happens. Moreover, the designer doesn't tell me
about the exceptions and it just looks like VS.NET semi-crashed (I found out
about the exceptions being thrown by using an external debug session).

What is a sure-fire way to tell if my component exists within a designer and
avoid these problems alltogether??

Jeffrey


Noozer

ungelesen,
31.12.2003, 19:11:2631.12.03
an

"Jeffrey Huntsman" <jhuntsman@__nospam__teletracking.com> wrote in message
news:%23eF9T$MpDHA...@TK2MSFTNGP09.phx.gbl...


Was there ever any answer to this?


James Hancock

ungelesen,
06.01.2004, 23:35:0606.01.04
an
There isn't an answer to this. I'm currently trying to convince the Whidby
developement team to fix this for Whidby so that Designtime = true in all
cases when a control is being displayed (directly in the case a of a control
on a form, or indirectly in the case of a control on a user control). Of
course I'm getting "it's by design"

Basically the DesignTime (designmode?) property is just a reflection of the
Site == null or not. So of course if you put a control on a user control,
the user control is not a design surface so site isn't there properly, and
it returns false instead of true as you'd logically think it should.

You see this if you wrap Win32 controls especially because they'll actually
work just like they would at runtime if you put them on a user control. Very
anoying.

This despirately needs to be fixed MS.

The only alternative is to pass the DesignTime property of the parent user
control (or whatever) to your hosted control as part of the constructor. I
have yet to find any other way of dealing with this.

James Hancock

"Noozer" <postm...@127.0.0.1> wrote in message
news:estH$u$zDHA...@TK2MSFTNGP10.phx.gbl...

DRaiko

ungelesen,
08.01.2004, 04:25:3608.01.04
an
Hallo,

The real problem is what is ment (and described in documentation) with
"DesignTime". I can not guarantee this to 100%, but the following
considerations seem to be convincing. If you inherit from a control,
then it is _not_ in design mode. You can not re-design it.
The derivated control is now in design mode. The original control
is not handled by the forms designer as a "designable" object.
And this is very important for its inntrnal life. If the DesignTime
property would make no difference between these two cases, we would
get much more troubles, since this property is the only way to know
is a control designable (at the moment) or not.

Maybe the question you want to get answered is not "is the control in
design mode" but "does it run under VS"? But this is quite a different
question. (Really, you can not read from a data base, because you are
on a different (development) computer, you initialize the control,
but you are not going to use it in a "runtime environment" you are
not going to solve "runtime tasks". This is not because it is in
design mode, but because you are in VS. These are two different
questions.)

To answere the _second_ question úsing the DesignTime property:
Would it be enough to make an abstract property (or virtual,
if you whant to use the control without first to inherit from it) and
override it on the top most level (if you have many inheritance levels)
so that the topmost control says, if _it_ is in design mode?

There may be an easyer way to find out whether the program runs
under VS. I've seen something in news groups, but don't aks me where.

And once more: If Whidby interprets "DesignMode" differently, my
controls will fail. And i see no workaround, if design mode would be
interpreted the way you whant it to be. Now the DesgnTime property is
the only one that answeres the question. If a different question would
be answered, then what should i do? And i am sure i am not alone.

Regadrs,
Raiko.

"James Hancock" <~ja...@darwinconsulting.com> wrote in message news:<eezXZeN1...@tk2msftngp13.phx.gbl>...

Igor Apostoloski

ungelesen,
14.01.2004, 08:50:3414.01.04
an
sorry if I just joined...
For DesignMode property I use my own Boolean :
All my apps start from the sub main (not directly form), so i have :

Public Module Startup
Public shared DesignMode as Boolean=true

public sub Main() 'this only executes when the app is run (never in
designer)!
DesignMode=false
application.run(new form1)
end sub
end module

And in all my assemblies, i do not test Component.DesignMode, but
Startup.DesignMode.

Hope I helped...

Igor

"DRaiko" <dra...@rhenus.de> wrote in message
news:3d60d02c.04010...@posting.google.com...

Don Kitchen

ungelesen,
27.01.2005, 16:11:4227.01.05
an
Great suggestion Igor!! I've been struggling with the same issues with
my inherited forms. The Solution Igor suggested worked great for me
since I was already using a module like his startup module (mine is
called WindowController) to start my app up.

Many people seem to get confused about this property
(Component.DesignMode) and how it works when you're working with
inherited forms or user controls. As mentioned before they built it
this way on purpose. Putting your own check in place is the easiest
and most effective way to get around this problem.

Thanks again!

joeycalisay

ungelesen,
14.02.2005, 20:48:0914.02.05
an
A post in the WF.Controls suggests the use of LicenseManager.UsageMode

--
Joey Calisay
http://spaces.msn.com/members/joeycalisay/


"Don Kitchen" <donki...@gmail.com> wrote in message
news:1106860302.3...@z14g2000cwz.googlegroups.com...

Uldis V.

ungelesen,
03.03.2005, 06:14:4003.03.05
an
Great solution joeycalisay.

Igors solution will have problems when there will be inherited forms
(or controls) from different projects (dll's) in the Solution. If
you'll put tis semaphore (Design) in main form - it will be
inaccessible from base dll's, if you'll put it in a dll - there will
be trouble accessing it outside this dll.

Uldis

"joeycalisay" <hcalisay@_spamkiller_codex-systems.com> wrote in message news:<u7lfoBwE...@TK2MSFTNGP15.phx.gbl>...

joeycalisay

ungelesen,
03.03.2005, 20:37:2803.03.05
an
Igor's solution is to include the said boolean in a module where most UI
logic can access it. There shouldn't be any problem with that.

Clarification:
LicenseManager.UsageMode check is good only if you want to check if control
is running at designtime within the constructor block or methods called
inside the constructor since control is not yet sited by then. UsageMode
will be at Runtime after that.


"Uldis V." <uld...@nelss.lv> wrote in message
news:7c01c9c4.05030...@posting.google.com...

0 neue Nachrichten