i'm using C# by the way.
i have a datagrid in my windows form and that datagrid's datasource is bound to a specific database using a MySQLConnection.
my problem now is that i want a user to actually enter some data into the datagrid and the data entered by the user should be reflected in the database(or the database should be updated with the new contents of the datagrid).
next i also would like to let the user copy and entire row of a data grid and that copied row would be pasted at the end of the data grid. i am currently using this code:
Expand|Select|Wrap|Line Numbers
- private void button1_Click(object sender, EventArgs e)
- {
- //DataRowView cdr = dataGridView1.Rows.
- int a = itemGrid.CurrentCell.RowIndex;
- //MessageBox.Show(a.ToString()); //good
- //dataGridView1.Rows.Add();
- int lastRow = itemGrid.NewRowIndex; //Rows.Count - 1;
- //MessageBox.Show(numRows.ToString());
- //itemGrid.Rows.Add();
- CopyRows(itemGrid, a, lastRow);
- }
- private void CopyRows(DataGridView DGVGrid, int SourceRowID, int DestinationRowID)
- {
- for (int j = 0; j < DGVGrid.Rows[SourceRowID].Cells.Count; j++)
- {
- DGVGrid.Rows[DestinationRowID].Cells[j].Value = DGVGrid.Rows[SourceRowID].Cells[j].Value;
- }
- }