Visual Inheritance in Visual C#

Here’s how you can inherit visual elements from a base form in Visual C# using Visual Studio 2008.

First, create 2 forms, one for the base form and one for the child form.

On the solution explorer on the upper-right pane, right click on the child form and select ‘view code’

After that, you will see something like this:

image

Just change csharptesting to the actual name of your project

image

Then change MainForm to the actual name of the base form you want to use.

Then select ‘build’->’build solution’ from your main menu.

image

Notice, that your child form will now have the same visual elements as your Main form. But also note that only the Main Form is editable, you cannot edit its child forms.