void DeleteRow() { foreach (DataGridView dgv in dgvList) { if (dgv.Visible) { DialogResult dr = MessageBox.Show("确定删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (DialogResult.Yes == dr) { List <DataGridViewRow> rl = new List <DataGridViewRow>(); foreach (DataGridViewCell cell in dgv.SelectedCells) { DataGridViewRow row = cell.OwningRow; dgv.Rows.Remove(row); } string cname = controllerDropList.SelectedValue as string; string IOType = IOTab.SelectedTab.Text; IODataCollection.dataTableType dtt = (IODataCollection.dataTableType)Array.IndexOf( Enum.GetNames(typeof(IODataCollection.dataTableType)), IOType); if (dgv.Rows.Count <= 0) { IODataCollection.FillEmptyTable(cname, dtt); } System.Data.DataTable table = dgv.DataSource as System.Data.DataTable; table.AcceptChanges(); } } } }
void ClearTable() { foreach (DataGridView dgv in dgvList) { if (dgv.Visible) { DialogResult dr = MessageBox.Show("确定清空?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (DialogResult.Yes == dr) { System.Data.DataTable table = dgv.DataSource as System.Data.DataTable; table.Clear(); string cname = controllerDropList.SelectedValue as string; string IOType = IOTab.SelectedTab.Text; IODataCollection.dataTableType dtt = (IODataCollection.dataTableType)Array.IndexOf( Enum.GetNames(typeof(IODataCollection.dataTableType)), IOType); IODataCollection.FillEmptyTable(cname, dtt); } } } }