Disable Cell Highlighting in a datagridview

前端 未结 10 1881
后悔当初
后悔当初 2020-12-08 13:30

How to disable Cell Highlighting in a datagridview, Highlighting should not happen even if I click on the cell.

Any thoughts please

10条回答
  •  無奈伤痛
    2020-12-08 14:07

    The only way I've found to "disable" highlighting is to set the SelectionBackColor and the SelectionForeColor in the DefaultCellStyle to the same as the BackColor and ForeColor, respectively. You could probably do this programmatically on the form's Load event, but I've also done it in the designer.

    Something like this:

    Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Me.DataGridView1.DefaultCellStyle.BackColor
    Me.DataGridView1.DefaultCellStyle.SelectionForeColor = Me.DataGridView1.DefaultCellStyle.ForeColor
    

提交回复
热议问题