When designing app in Visual Studio (C#), if I know that I will have a certain number of DataGridViews that all have same properties (like width, height, color, some other properties like: disable option to directly edit rows, etc.) is it ok to make my own class ("myDataGridView") that inherits DataGridView class and make all adjustments there, and then just instantiate that class later in code? Like this:
//my class:
class myDataGridView : DataGridView
{
this.BorderStyle = <someValue>
this.ColumnCount = <someValue>
//etc.
public void method1()
{
//some code...
}
public void method2()
{
//some code...
}
}
//instantiate it somewhere:
myDataGridView dgv1 = new myDataGridView();
myDataGridView dgv2 = new myDataGridView();
myDataGridView dgv3 = new myDataGridView();
Is that ok regarding OO principles? My friend says that putting code like
this.BorderStyle = <someValue>
in myDataGridView class is bad practice because adjusting properties like that will overrun properties of dataGridView which some other developer may adjusted visually in Visual Studio, if you know what I mean. Does that matter? I mean, if I want to treat my DataGridView as an object then it can have its properties and behavior, right? And having code that adjusts properties of DataGridView in my class is ok, readable, and every other developer who wants to change some properties can change it in myDataGridView class. It that kind of practice bad or wrong? If it is, what is the best practice when you know your app will have many DataGridViews which have same properties/behaviour? Thank you.