禁用单元格突出显示在一个DataGridView单元格、突出、DataGridView

2023-09-02 10:45:30 作者:缺烟缺酒缺幸福

如何禁用单元格突出显示在一个DataGridView, 如果我点击单元格高亮不应该发生,即使。

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

任何想法请

推荐答案

我发现为禁用,突出的唯一方法是设置的SelectionBackColor SelectionForeColor DefaultCellStyle 以相同背景色前景色,分别。你也许可以做到这一点编程的表单中的加载事件,但我已经在设计师也做到了。

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