class CustomDataGridView : System.Windows.Forms.DataGridView{
public CustomDataGridView(DataTable dataSource) {
public CustomDataGridView(DataTable dataSource)
///Set the base data source to the passed //DataTable parameter
base.DataSource = dataSource;
}
Interface ISaveableControl{ void Save();}
class CustomTextBox : System.Windows.Forms.TextBox, ISaveableControl{ public CustomTextBox(string defaultValue) { base.Text = defaultValue; } public void Save() { ///Go to the database and update the associated record with the associated value }}class CustomComboBox : System.Windows.Forms.ComboBox, ISaveableControl{ public CustomTextBox(string defaultValue) { base.Items.Add(defaultValue); base.Text = defaultValue; } public void Save() { ///Go to the database and update the associated record with the associated value }}
foreach(Control ctrl in this.Controls){ if(ctrl is ISaveableControl) { ((ISaveableControl)ctrl).Save(); }}