开发者

How to delete a record from datagridview by clicking on a 'Delete' DataGridViewLinkColumn

开发者 https://www.devze.com 2023-02-23 06:48 出处:网络
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 b

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号