I have set the AllowUsersToAddRow property to true which rows at the bottom all the time.
I want to control this with the click of the button. On clicking of a button I want to add a new row to datagridview. and allow editing until saved.
My grid is noneditable for oldrows and editable for newrows........I have set
grid.readonly false,col.readonly fale.,grid.rowtemplate.readonly true......This makes my grid noneditable...
Now with this scenario
If I use AllowUserToAddRows=true
private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e)
if (this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].IsNewRow)
this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].ReadOnly = false;
I get editable row which is not added as a result of a click of button/....
If I try to set AllowUserToAddRows =false and then try on click of button
private void button1_Click(object sender, EventArgs e)
DataTable dt = ((DataSet)((BindingSource)this.dataGridView1.DataSource).DataSource).Tables;
DataRow dr = dt.NewRow();
dr["CustomerID"] = "jyo";
dr = "item";
this.dataGridView1.VirtualMode = true;
//this.dataGridView1.RowCount = dt.Rows.Count + 1;
this.dataGridView1.AllowUserToAddRows = false;
This adds a row which is controlled by buttonclick but is noneditable
I want a controlled row added on click of button which is editable though old records in grid is noneditable.