Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to change selected row in datatable?

$
0
0

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[i][j] = row.Cells[j].Value; }

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




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>