簡體   English   中英

如何刪除 DataGridView 最后一行 ButtonColumn 按鈕 c#?

[英]How to remove DataGridView last row ButtonColumn Button c#?

我正在 c# 中執行 windows 應用程序。 誰能幫我解決這個問題。 我在包含 ButtonColumn 和其他 3 列的表單中使用了 datagridview。 使用最后一行中的列的總值生成表單。 問題是我想刪除最后一行(總計行)中的按鈕列按鈕。 在這里,我使用本地數據庫表作為 DataGridView 的數據源。 請幫我。 這是 output

加載數據后,您可以嘗試訪問該單元格並將其設為“較少按鈕”。 以下代碼來自我的腦海,尚未經過測試,但值得一試。


  int DetailColumnIndex = 0; //or whatever it is
  var LastButtonCell =(DataGridViewButtonCell)myDataGridView.Rows[myDataGridView.Rows.Count-1]
                                       .Cells[DetailColumnIndex];

  LastButtonCell.Value = null;
  LastButtonCell.FlatStyle  = FlatStyle.Flat;  

然后確保當它被點擊時,事件處理程序檢測到它是最后一個按鈕並且什么都不做

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM