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(); } } } }
private void PasteData() { if (controllerDropList.Items.Count > 0) { string pasteText = Clipboard.GetText(); string IOType = IOTab.SelectedTab.Text; IODataCollection.dataTableType dtt = (IODataCollection.dataTableType)Array.IndexOf( Enum.GetNames(typeof(IODataCollection.dataTableType)), IOType); DataGridView dgv = new DataGridView(); switch (dtt) { case IODataCollection.dataTableType.Input: dgv = inputDGV; break; case IODataCollection.dataTableType.Output: dgv = outputDGV; break; case IODataCollection.dataTableType.Limit: dgv = limitDGV; break; } string controllerName = controllerDropList.SelectedValue as string; PasteFormPreviewWindow pfp = new PasteFormPreviewWindow(pasteText, dgv, dgvList, controllerName.Split('-')[0]); pfp.ShowDialog(); if (pfp.result) { DataTable ct = pfp.pTable; IODataCollection.AddTable(dtt, controllerName, ct); switch (dtt) { case IODataCollection.dataTableType.Input: inputDGV.Sort(inputDGV.Columns["IOName"], ListSortDirection.Ascending); break; case IODataCollection.dataTableType.Output: outputDGV.Sort(outputDGV.Columns["IOName"], ListSortDirection.Ascending); break; case IODataCollection.dataTableType.Limit: limitDGV.Sort(limitDGV.Columns["IOName"], ListSortDirection.Ascending); break; } } } else { MessageBox.Show("请先添加控制器", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); childItemManageControllers.PerformClick(); } }
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); } } } }
private void CheckErrorCell(IODataCollection.dataTableType dtt, string controllerName) { }