How to make Designer ignore code

Z

ZBINContact

Is there a directive or a command to outline code that I want the
Designer to ignore? I am creating a group of user controls with
extended self-checking functionality. In each user control, I call a
self-check function from a Load event handler, which checks ranges or
more complex program-related situations at load time and throws up a
messagebox and at times changes the control's properties if the
situation demands it. This helps our engineers immensely, but the
unfortunate side effect is that everytime i rebuild or refresh the
Designer window in any way, this self check is compiled by the
Designer and it will change all the values and throw up
messageboxes.

In summary:

Can I somehow delineate a section of code to be ignored by the
Designer (like #DEBUG tells the compiler to ignore it in Release
Mode)?

Thank you.
Clayton
 
C

Chris Shepherd

In summary:

Can I somehow delineate a section of code to be ignored by the
Designer (like #DEBUG tells the compiler to ignore it in Release
Mode)?

A co-worker of mine found a way of doing it a while ago:

if (LicenseManager.UsageMode =! LicenseUsageMode.Designtime)
{
// Do run-time only stuff.
}


Chris.
 
C

Chris Shepherd

Chris said:
if (LicenseManager.UsageMode =! LicenseUsageMode.Designtime)

I really have to start writing things in a code window...
the "=!" should be "!=" obviously.

Chris.
 
M

Mikus Sleiners

Note that DesignMode will only work outside of the constructor, use the
LicenseManager stuff if you need this to work within constructor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top