How to delete a record from datagridview by clicking on a 'Delete' DataGridViewLinkColumn
How to delete a row from DataGridView by clicking on delete hyperlink.Currently, the record is deleted by selecting the entire row. but I need to delete the row only upon clicking on 'Delete' link button.The following code is used to remove the row upon selecti开发者_如何学编程ng the row.Please help me how to remove the row upon clicking on Delete Link(Not selecting the Row).
foreach (DataGridViewRow row in datagvRelation.SelectedRows)
{
datagvRelation.Rows.Remove(datagvRelation.CurrentRow);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
dataGridView1.Rows.RemoveAt(e.RowIndex);
}
}
Here you can replace zero with your columnindex containing the link...
精彩评论