There are several ways you can do this; I'll outline here what I think is the
simplest way, which may, or may not, meet the OP's goals. In the future I intend to publish an article here on CP about a "fancier" way to do this.
But, first, note that there is
already a kind-of inheritance of Color, and Font, built-in: when you create a WinForm, and you set its Font and Fore/Back- Color properties: when you drag-drop Controls onto that Form certain Types of Controls will inherit the Font and Fore/Back-Color properties (for example, Panel, GroupBox, Button, Label, PictureBox all inherit the BackColor). For the Controls Button, and Label, their Text will inherit the ForeColor of the Form.
How-to, Simple:
1. Create your main UI form as usual.
2. Add another Form to your Project, give it a name like "ThemeForm."
a. configure your ThemeForm's Size, Color, Font, etc., settings so they define the "common look and feel" that you want other Forms to inherit.
3. Add other Forms to your Project: change their Class declaration so they inherit from your ThemeForm:
public partial class SecondaryForm1 : ThemeForm
{
public SecondaryForm1 ()
{
InitializeComponent();
}
}
Discussion:
1. If you put Controls on your "ThemeForm," then those Controls will also appear in "locked" form on any Form that inherits from "ThemeForm." So, if you define a Button Click EventHandler for a Button on the ThemeForm, and you click that Button in a derived Form, the EventHandler defined in the ThemeForm will fire.
That may be a behavior you don't want, or a behavior you will want to take advantage of for enabling certain types of communication between inherited Forms.
For example, if I define this Click EventHandler for 'button1 in the ThemeForm:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(string.Format("in ThemeForm: firing from: {0}",(sender as Control).Parent.Name ));
}
, and I click on 'button1 in a derived Form named 'Form2, I will get the message: "firing from: Form2"
How to "get rid of" inherited Controls you don't want to use in derived Forms (not as simple as you might think), and how to add EventHandlers to the derived Controls, while either removing or leaving active, its inherited EventHandlers ... is something I intend to address fully in the article I plan to write.
2. Caution: if things get "messed up" so you get an error message trying to show the Design View of an inheriting Form ... but you can still run your application ... just save everything in the current Project, close it, and then re-open it in Visual Studio.