Reputation: 313
I'd like to know how is it possible to set a background image for all my windows forms, also other properties such as disable controlbox, minimizebox, etc. I read from somewhere I could use inheritance, how is this possible? Should I create a base class with all these settings? So far I've just been able to import my image into the resources
Upvotes: 1
Views: 93
Reputation: 1989
Sure you can use inheritance, you can have a class and make all the Form classes inherit from the base one. Here's an example:
public partial class Form1 : BaseForm
{
public Form1()
{
InitializeComponent();
}
}
public class BaseForm : Form
{
protected override void OnLoad(EventArgs e)
{
this.ControlBox = false;
this.MinimizeBox = false;
this.MaximizeBox = false;
this.BackColor = Color.Cyan;
base.OnActivated(e);
}
}
Upvotes: 1
Reputation: 7467
Yes it is possible, and it has a name : visual inheritance. You can google that term and get a lot of useful information on how to do it.
You can start here : https://msdn.microsoft.com/en-us/library/bx1155fz%28v=vs.110%29.aspx
The idea is basically the same as with any other inheritance. So it is not difficult at all.
Upvotes: 0
Reputation: 10285
MyForm
Inherited from System.Windows.Forms
.MyForm
in your all other Forms.Upvotes: 0