Dot-Net
WinForms - DataGridView - 未選擇單元格
有沒有辦法讓 DataGridView 沒有選擇單元格?我注意到即使它失去了 focus() 它也至少有一個活動單元格。是否有另一種模式允許這樣做?或其他一些技巧?
DataGridView.CurrentCell 屬性可用於清除焦點矩形。
可以將此屬性(DataGridView.CurrentCell)設置為null來臨時移除焦點矩形,但是當控制項接收到焦點並且該屬性的值為null時,它會自動設置為FirstDisplayedCell屬性的值。
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcell.aspx
在選擇更改事件上將 DataGridView.CurrentCell 設置為 null 的問題是不會命中以後的事件(如點擊)。
對我有用的選項是將選擇顏色更改為網格顏色。因此選擇將不可見。
RowsDefaultCellStyle.SelectionBackColor = BackgroundColor; RowsDefaultCellStyle.SelectionForeColor = ForeColor;