Form inheritence

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

Can someone tell me how to create a form inherit from another form ?
In my project, I have created a form with buttons and groupbox to be used as
ancestor, how to create a form inherit from this form ?
 
In my project, I have created a form with buttons and groupbox to be used
as ancestor, how to create a form inherit from this form ?

Change the code in the form class

public class MyForm : MyBaseForm
 
Alan said:
Can someone tell me how to create a form inherit from another form ?
In my project, I have created a form with buttons and groupbox to be used as
ancestor, how to create a form inherit from this form ?

You can also do it by choosing Inherited Form as the new item type.
For example:

Right click on the project.
Choose Add -> Windows Form
Choose Inherited Form

You should then be presented with a list of forms in the project to
choose from.
 
Hi,

Yes now I can create a inherited form.
However, it seems does not allow me to move the controls in my inherited
form.
I got a groupbox and would like to add another text box inside this groupbox
but it does allow me to.
 
Alan said:
Hi,

Yes now I can create a inherited form.
However, it seems does not allow me to move the controls in my inherited
form.
I got a groupbox and would like to add another text box inside this groupbox
but it does allow me to.

You need to change the Protection setting of the controls on the base
form from Private (the default) to at least Protected so that they are
changeable by inheriting forms.
 
Thanks Bruce.
I just what would happen if I have up to hundred controls in my ancestor
form and need to change it to Proteced manually.
Is that any shortcut to change the controls from private to proteced ?
 
You can edit the definitions that Visual Studio Designer inserts into
your .cs file. Or, if you're using .NET 2.0, you'll have to find the
other half of your Form's partial class, the half written by Visual
Studio. If you close the Designer, change things from private to
protected in code and then restart the Designer, all should be well.

Within the Designer itself... well, it's select, change, select,
change, ....
 
Hi,

Now I have a problem in creating an inherited form.
I created a Class Library and a base form in it, then want to add a new form
inherited from that base form.
VS 2005 ask me about the base form but only limited to a dll. If I choose to
inherit from the base form then it cannot let me thro the process, only
select a dll.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top