Abstract Forms using WinForms
Posted
by
pm_2
on Stack Overflow
See other posts from Stack Overflow
or by pm_2
Published on 2011-01-14T15:31:54Z
Indexed on
2011/01/14
15:53 UTC
Read the original article
Hit count: 336
I’m trying to achieve a similar affect in a WinForms application as a master form does with ASP.NET. My initial thoughts on this were to create a base form and declare it as abstract, but the compiler doesn’t seem to let me do this.
public abstract partial class Master : Form
{
public Master()
{
InitializeComponent();
}
}
So I have two questions:
- Why will the compiler not let me do this? Am I using the wrong syntax or is this a genuine restriction.
- Can anyone suggest a workaround or better way to do this?
EDIT:
InitializeComponent code:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.Menu = this.mainMenu1;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Text = "Master";
this.AutoScroll = true;
}
© Stack Overflow or respective owner