WinForm中DataGridView添加,删除,修改操作具体方法

  private void gcConfigShow_CellClick(object sender, DataGridViewCellEventArgs e)

  {

  if (e.RowIndex < 0) return;

  DataGridView _dgv = (DataGridView)sender;

  string _opWay = _dgv.Rows[e.RowIndex].Cells["OpWay"].Value.ToString();

  switch (_opWay)

  {

  case "00":

  ThreadSafeOpRadioButton(rbCgClose, true);

  break;

  case "01":

  ThreadSafeOpRadioButton(rbCgOpen, true);

  break;

  case "02":

  ThreadSafeOpRadioButton(rbSaveOne, true);

  break;

  }

  string _opCtuch = _dgv.Rows[e.RowIndex].Cells["OpCtuCh"].Value.ToString();

  for (int i = 0; i < _opCtuch.Length; i++)

  {

  if (i == 0)

  ThreadSafeCheckBox(ckch1, _opCtuch[i].Equals('1'));

  if (i == 1)

  ThreadSafeCheckBox(ckch2, _opCtuch[i].Equals('1'));

  if (i == 2)

  ThreadSafeCheckBox(ckch3, _opCtuch[i].Equals('1'));

  if (i == 3)

  ThreadSafeCheckBox(ckch4, _opCtuch[i].Equals('1'));

  if (i == 4)

  ThreadSafeCheckBox(ckch5, _opCtuch[i].Equals('1'));

  if (i == 5)

  ThreadSafeCheckBox(ckch6, _opCtuch[i].Equals('1'));

  if (i == 6)

  ThreadSafeCheckBox(ckch7, _opCtuch[i].Equals('1'));

  if (i == 7)

  ThreadSafeCheckBox(ckch8, _opCtuch[i].Equals('1'));

  }

  string _opTime = _dgv.Rows[e.RowIndex].Cells["OpTime"].Value.ToString();

  decimal _time;

  if (decimal.TryParse(_opTime, out _time))

  ThreadSfeOpUpDown(UpDownTime, _time);

  }