Can I define a conditional code block that is not compiled when a form is loaded into the designer?

  • Thread starter Thread starter Mountain Bikn' Guy
  • Start date Start date
M

Mountain Bikn' Guy

I have a block of code that compiles and excutes correctly. However, it is
not compatible with the forms designer. Is it possible to conditionally
exclude this small block of code when the form is loaded into the designer?
I can manually comment it out now, and then the form loads into the designer
properly. But I need a way to do this without manually changing the code.

I read a post that mentioned a technique for doing this a long time ago, but
I cannot locate that post at this time.

Thanks
Dave
 
You can wrap the code you don't want executed in the designer with:
if( !this.DesignMode )
{
//code not executed in DesignMode
}
 
Michael,
Thanks! That works perfect. (And it's a lot simpler than what I vaguely
remember seeing in that prior post a long time ago.)
Dave
 

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

Back
Top