private void btn_add_Click(object sender, EventArgs e) { using (LedgerChange dialog = new LedgerChange()) { if (dialog.ShowDialog() == DialogResult.OK) { ledgerModule.Add(dialog.LedgerModuleChange); dataGridView1.DataSource = new List <LedgerModule>(); dataGridView1.DataSource = ledgerModule; dataGridView1.Refresh(); } } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RowUpdateClick(object sender, DataGridViewCellEventArgs e) { LedgerModule ledger = ledgerModule[e.RowIndex]; using (LedgerChange dialog = new LedgerChange(ledger)) { if (dialog.ShowDialog() == DialogResult.OK) { ledgerModule[e.RowIndex] = dialog.LedgerModuleChange; dataGridView1.Refresh(); } } }