views:

35

answers:

1
+1  Q: 

Visual Inheritance

Hi. I have same settings for all of my forms for example color , font , align, etc How can i do these settings for one form and inheriting it on all forms. thanks. Edition 1 : i am using Windows Forms.

+2  A: 

One way would be to extend/inherit from the form class, set the properties the way you like in your constructor, and let your forms inherit from that class.

Something like:

class RedForm : Form
{
    public RedForm() { BackColor = Color.Red; }
}

and then make your forms based on RedForm rather than Form.

cHao
@cHaoThanks.WHich one better? extend or inherit?you said : "set the properties the way you like in your constructor"Where?please give me small sample for inheriting.
shaahin
@shaahin: Extend and inherit mean the same thing in this case -- to create a subclass. It's just that some languages use "extend" and some "inherit", and you didn't specify the language.
cHao
@cHaothank you.please describe more about your answer.and give me small sample if possible.
shaahin
@shaahin: edited.
cHao