Adding Extra row at Checkbox click in datagridview

N

Neeraj

Hi guys
I have strange problem I added check box using
"DataGridViewCheckBoxColumn"
It works fine but when i check it at last row it add extra row. i
tried so much but i am not able to prevent to do this.
you have any idea please share with me

Thanks
Neeraj Kumar
 
C

ClayB

Try handling the cellmousedown event and set any checkbox cells on the
last row to be readonly.

void dataGridView1_CellMouseDown(object sender,
DataGridViewCellMouseEventArgs e)
{
if (dataGridView1[e.ColumnIndex,
e.RowIndex].ValueType.Equals(typeof(bool)))
{
dataGridView1[e.ColumnIndex, e.RowIndex].ReadOnly =
(e.RowIndex == dataGridView1.RowCount - 1);
}
}
===============
Clay Burch
Syncfusion, Inc.
 
N

Neeraj

Try handling the cellmousedown event and set any checkbox cells on the
last row to be readonly.

void dataGridView1_CellMouseDown(object sender,
DataGridViewCellMouseEventArgs e)
{
if (dataGridView1[e.ColumnIndex,
e.RowIndex].ValueType.Equals(typeof(bool)))
{
dataGridView1[e.ColumnIndex, e.RowIndex].ReadOnly =
(e.RowIndex == dataGridView1.RowCount - 1);
}}

===============
Clay Burch
Syncfusion, Inc.


thanks it works fine.

Neeraj Kumar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top