I have a dataGridView
that is bound to a tableAdaptor
, behind this table is a MS SQL server database.
In Form1_Load
i have dataGridView1.ReadOnly = true;
and in the dataGridView1
controls on the form i have Enable Editing
selected.
I then fill the dataGridView
at run time here: stockTableAdapter.Fill(sIMSDataSet.Stock);
What i am trying to do, is have a user select any cell within a row and click a button which then allows the user to edit that row.
I have tried various ways to get the row the user currently has selected to be set to ReadOnly=flase
but i can't get it to work.
This is what i have tried:
private void button7_Click_1(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow.ReadOnly == true)
{
dataGridView1.CurrentRow.ReadOnly = false;
dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
}
}
And i have also tried the answer is this question:
unable to set Row.Readonly=false in Datagridview in winforms
The user suggests in his testing he was not able to set the row to ReadOnly=flase
on databound dataGridViews
. But seeing as the answer is now 6 years old i was hoping there was a way to do it now.