How to change selected row in datatable?

  • Thread starter Thread starter Vejrazib
  • Start date Start date
V

Vejrazib

Guest
I have another problem. I have binded datagridview, and when I doubleclick on row in it all cell values are "transformed" into textboxes. What I wanna do is when I change textbox value there also have to be made changes in datagridview and datatable. So far I get to change only first row of datagridview, not the selected. Here is my code:


private void buttonEdit_Click(object sender, EventArgs e)
{
int i = 0;
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
for (int j = 0; j < dataGridView1.ColumnCount; ++j)
{
competitorDataSet.Growns.Rows[j] = row.Cells[j].Value;
}


++j;

}
competitorDataSet.Growns.Rows[0] = textStN.Text;
competitorDataSet.Growns.Rows[1] = textN.Text;
competitorDataSet.Growns.Rows[2] = textSN.Text;
competitorDataSet.Growns.Rows[3] = textC.Text;
competitorDataSet.Growns.Rows[4] = textYB.Text;
this.grownsBindingSource.EndEdit();
if (dataGridView1.BindingContext[competitorDataSet.Growns] != null)
{
dataGridView1.BindingContext[competitorDataSet.Growns].EndCurrentEdit();
}
this.competitorDataSet.Growns.AcceptChanges();



Continue reading...
 
Back
Top