Reputation: 1469
I have an application with several DataGridView controls. I would like to create a master control or component (I'm not sure which one to use) where I can define basic coloring and behavior. However, since all DataGridView controls have different columns in the application I want to define columns after placing a new instance on the form and not in the master form.
Can you suggest a way to do this? Thanks in advance.
Upvotes: 0
Views: 565
Reputation: 4856
Have something like your own MasterGridView where you define all common behavior, colour, etc.. & then inherit all respective datagridviews from this one.
public class MasterDataGridView: System.Windows.Forms.DataGridView
{
public MasterDataGridView()
{
BackColor = Color.Yellow;
// define other behaviours
}
}
public class OrdersDataGridView : MasterDataGridView
{
// data binding, column addition etc can be handle in respective grid views
}
public class ReportsDataGridView : MasterDataGridView
{
}
... etc.
Upvotes: 3