且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 datagridview 中禁用单元格突出显示

更新时间:2023-12-03 12:37:28

我发现禁用"突出显示的唯一方法是设置 SelectionBackColorSelectionForeColorDefaultCellStyle 中分别与 BackColorForeColor 相同.您可能可以在表单的 Load 事件上以编程方式执行此操作,但我也在设计器中执行此操作.

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.

像这样:

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