Visual Inheritance & compact framework?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Does anyone know how to make Visual Inheritance work using VS.NET 2003 and
the .NET Compact Framework? A marketing article on msdn said its one of the
benefits of VS.NET over embedded programming...However, I can't find out how
to do it. I went through a walkthrough for a normal application where I
created a base form in a class library. I then created a standard windows
app & added a reference to the class library. Then I (per the walkthrough)
click on the project --> Add Inherited form. This is for a non-"Smart
Devices" type of project. When I follow the same for a "Smart Devices" type
of project I do NOT see the option to add an "Inherited form". I thought
I'd try to go a little and changed the "inherits system.forms........" line
to "inherits myclasslib.frmbase" BUT after doing this, I couldn't go to the
design mode of the form to add a new button???

I'm hoping that this is one of those scenarios where the option I'm looking
for is right in front of me...but..........help! Anyway?

I'm actually looking at this functionality because I want to create a bunch
of forms that share common features like menues, certain labels,.....

Thanks,
Brian Pryor
 
Well, though it is not suported on the designer you have some workarounds.
For example what I do is the following:
- Define a preprocessor directive, for example: _DESIGNER = 1
- Change the form code the following way:

Public Class frmForm
#if _DESIGNER = 1 Then
Inherits System.Windows.Forms.Form
#Else
Inherits frmBase
#End if

....
End Class

Then when you need to open the form to design it, you have to, prior to it,
put the _DESIGNER equals to 1.
Then when you need to compile the code, close all design view of the forms,
and put the _DESGINER variable to 0

For me it works great!

Roberto
 
Robert,

This is one of the best tips that I have seen in a long time and it has just
solved a major headache for me. Thankyou.

In return, I will save you some trouble. VS2003 has a default flag/constant
that can be used to identify when something is running in the designer,
"DESIGN" hence:

#if DESIGN
public class Form2 : System.Windows.Forms.Form
#else
public class Form2 : Form1
#endif
{
...
}

or

Public Class frmForm
#if _DESIGNER = 1 Then
Inherits System.Windows.Forms.Form
#Else
Inherits frmBase
#End if
....
End Class

I hope you find this as useful as I found you suggestion.

Cheers,

Martin Robins.
 
Back
Top