[英]Need to get the first cells of a selected row in datagridview before delete it
private void button2_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow item in this.pronv.SelectedRows)
pronv.Rows.RemoveAt(item.Index);
}
上面是刪除所選行的代碼,但在此之前,我需要從該行的第一個單元格獲取數據。 但是當我嘗試:
pronv.SeletedRows.Cells[0]
錯誤說:
沒有擴展方法“單元”
我被困在這里,請幫忙。
SelectedRows
是行的集合。 枚舉選定的行時,應獲得某一特定行的單元格:
foreach (DataGridViewRow item in this.pronv.SelectedRows)
{
object data = item.Cells[0].Value;
pronv.Rows.RemoveAt(item.Index);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.