totmoto
totmoto

Reputation: 19

C# DataGridView Row add dataGridView button text not change

I am reading xml file in winform and displaying data in DataGridView DataGridView read in xml has a button, and when the button is clicked, the button's text is changed.

DataGridViewButtonCell btnStart = null;
btnStart = (DataGridViewButtonCell)(DataGridView.Rows[e.RowIndex].Cells[0]);
var btnType = btnStart.Value.ToString();
btnStart.UseColumnTextForButtonValue = false;

In this result I try to re-read the XML and append the ROW

DataGridView.DataSource = dataSet.Tables[0];

Is there a way to add ADD to the DataGridView without changing the text of the button in the DataGridView that is shown?

Upvotes: 2

Views: 119

Answers (1)

John V
John V

Reputation: 1374

This line of code: DataGridView.DataSource = dataSet.Tables[0];

Doesn't read a row, it resets the entire DataGridView, which is why the button changes. If you want to append a row, then add a row to the Table the DataGridView is displaying, don't replace the whole thing.

Upvotes: 1

Related Questions