Пример #1
0
 private void editRowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (tabControl.SelectedIndex == -1) {
         return;
     }
     DataGridView dgv = ((DataGridView)tabControl.TabPages[tabControl.SelectedIndex].Controls[0]);
     DataTable dT = (DataTable)dgv.DataSource;
     if (dgv.SelectedRows.Count == 0) {
         MessageBox.Show("No rows were selected", "No Row Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     RowEdit rE = new RowEdit(dbFile, dT, dgv.SelectedRows[0].Index);
     if (rE.ShowDialog() == DialogResult.OK) {
         dT.DefaultView[dgv.SelectedRows[0].Index].Row.ItemArray = rE.dr.ItemArray;
     }
 }
Пример #2
0
 private void addRowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (tabControl.SelectedIndex == -1) {
         return;
     }
     DataGridView dgv = ((DataGridView)tabControl.TabPages[tabControl.SelectedIndex].Controls[0]);
     if (dgv.Columns.Count == 0) {
         return;
     }
     DataTable dT = (DataTable)dgv.DataSource;
     RowEdit rE = new RowEdit(dbFile, dT, -1);
     if (rE.ShowDialog() == DialogResult.OK) {
         dT.Rows.Add(rE.dr);
     }
 }