Getting #If DESIGN to work.

J

Jan Obrestad

I'm working on the Compact Framework 1.0

A while ago I made this workaround to fixed the fact that the compact
framework does not have designer support for a forms that does not
directly inherit from System.Windows.Forms.Form

#If DESIGN Then
Inherits System.Windows.Forms.Form
#Else
Inherits BaseForm
#End If

This worked fine, it inherited from System.Windows.Forms.Form when I
viewed it in the designer, but it inherited BaseForm while compiling.

But when I try it now , the DESIGN flag is not set when the form is
viewed in design mode, so it inherits BaseForm in design mode as well.

Any ideas how I can get it to work again?

Jan
 
G

Guest

Did you set the DESIGN as a conditional compilation constant in your project
properties?
 
J

Jan Obrestad

Alex said:
Did you set the DESIGN as a conditional compilation constant in your project
properties?

No I did not, in fact I made no changes to the project whatsoever.
My understanding was that the DESIGN constant was set when you viewed a
form in design mode, but not else.

By setting DESIGN as a conditional compilation constant in the project,
it will always inherit System.Windows.Forms.Form which will give me
errors while trying to used methods defined in BaseForm.

Jan
 
I

Ilya Tumanov [MS]

It's a compile time macro, not a runtime constant. For runtime check in VS
2005/NETCF V2 you could try this:

if( myComponent.Site != null && myComponent.Site.DesignMode )
{
// Design mode
}
else
{
// Runtime mode
}

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

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