protected virtual void CloneCurrentRow() { DataGridViewRow row = DataGrid.CurrentRow; if (row != null) { DialogResult result = System.Windows.Forms.DialogResult.None; if (row.DataBoundItem != null && row.DataBoundItem is ICloneable) { var record = ((ICloneable)row.DataBoundItem).Clone(); BeforeEditRowEventArgs e = new BeforeEditRowEventArgs(record); OnBeforeEditRow(e); if (!e.Cancel) { result = EditRecord(record); OnAfterEditRow(new AfterEditRowEventArgs(record)); } else { result = DialogResult.Cancel; } } if (result == DialogResult.OK) { DataGrid.Refresh(); } } }
protected virtual void OnBeforeEditRow(BeforeEditRowEventArgs e) { if (BeforeEditRow != null) { BeforeEditRow(this, e); } }
protected virtual void EditCurrentRow() { DataGridViewRow row = DataGrid.CurrentRow; if (row != null) { DialogResult result; if (row.DataBoundItem != null) { object record = row.DataBoundItem; BeforeEditRowEventArgs e = new BeforeEditRowEventArgs(record); OnBeforeEditRow(e); if (!e.Cancel) { result = EditRecord(record); OnAfterEditRow(new AfterEditRowEventArgs(record)); } else { result = DialogResult.Cancel; } } else { result = EditRecord(row); } if (result == DialogResult.OK) { DataGrid.Refresh(); } } }