Re: How to tell if a component function is executed at design time or runtime?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Martin,

Every Type derived from System.ComponentModel.Component ...

It should really say, "Every class that derives from
System.ComponentModel.Component ..."

Just wanted to clear that up so you didn't think I was referring to the
System.Type class :)

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.com> wrote in message
news:evnUkGSBHHA.3928@xxxxxxxxxxxxxxxxxxxxxxx
Hi Martin,

Every Type derived from System.ComponentModel.Component (which includes all
Controls and the Form class itself) has a Site property. Visual Studio sets
the Site when the Component is being hosted by a designer. In that case the
Site.DesignMode property will be true. At runtime, check if Site is null or
Site.DesignMode is false:

if (Site == null || !Site.DesignMode)
{
// not in design mode
}

You can't perform this check in the constructor, however, because VS hasn't
set the Site property yet. (The Site property can't be set by VS until
after the Component is constructed, obviously)

--
Dave Sexton

"Martin Arvidsson" <yeahright@xxxxxx> wrote in message
news:uUcoKQRBHHA.2276@xxxxxxxxxxxxxxxxxxxxxxx
Hi!

I have developed a component that creates a lookup for selecting values.
At designtime i want to display the windows as well but with certain
criterias.
is there a property or something to look at that tells mee if its
designtime or runtime?

Regards
Martin





.


Quantcast