[英]remove datagridviewcheckbox on specific row/cell
我有一個帶有動態復選框的datagridview
Dim checkBoxColumn As New DataGridViewCheckBoxColumn()
checkBoxColumn.HeaderText = ""
checkBoxColumn.Width = 30
checkBoxColumn.Name = "checkBoxColumn"
DataGridView1.Columns.Insert(0, checkBoxColumn)
我需要刪除我嘗試的行(0)和單元格(0)上的復選框
DataGridView1.Rows(0).Cells(0).Visible = False
但顯示有一個只讀屬性
這是有關如何執行此操作的簡短C#
示例,應該很容易翻譯:
void dgv_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
DataGridView dgv = (DataGridView) sender;
if (e.RowIndex == 0 && e.ColumnIndex >= 0 && dgv.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn) {
e.PaintBackground(e.CellBounds, true);
e.Handled = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.