Hi ,
I need to develop a windows application using .net 1.1.
In some form i want Datagrid with button column for each row on click of each button i want to delete that particular row.
Can any please help me on doing it.
Printable View
Hi ,
I need to develop a windows application using .net 1.1.
In some form i want Datagrid with button column for each row on click of each button i want to delete that particular row.
Can any please help me on doing it.
Hi.
Maybe this can help you:
- add a new DataGridView component on form
- add your columns, the first being a DataGridViewButtonColumn (ColumnType property)
- override CellClick event of the DataGridView
With regards,Code:private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if ((e.ColumnIndex == 0) && (e.RowIndex != dataGridView1.Rows.Count-1)) //if clicked on new row
if (MessageBox.Show("Are you sure you want to delete row " + e.RowIndex.ToString() + " ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//delete current row
dataGridView1.Rows.RemoveAt(e.RowIndex);
}
}
Dan Fat