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
2010-08-09 07:00:58
@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
2010-08-09 07:10:13
@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
2010-08-09 07:20:51
@cHaothank you.please describe more about your answer.and give me small sample if possible.
shaahin
2010-08-09 07:23:10
@shaahin: edited.
cHao
2010-08-09 07:58:00