How to prevent the blackout selection when AllowSelection is set to None or Any in WinForms GridControl, GridGroupingControl and GridDataBoundGrid ?
Selection backcolor
By default, the selected rows or columns or cells are highlighted with AlphaBlend color. The Selection Backcolor is highlighted with Black color, by changing the AllowSelection property to None. The following image illustrates the exact issue.
As per the architecture, the Selection Backcolor is removed from the graphics when changing AllowSelection to None. This article provides the information about how to resolve it.
Solution
To resolve the Selection Backcolor issue, the GridSelectionFlags.AlphaBlend property can be used along with the GridSelectionFlags.None property as GridSelectionFlags.None | GridSelectionFlags.AlphaBlend while setting the AllowSelection to None.
C#
private void noneAllowSelection_CheckedChanged(object sender, EventArgs e) { //Sets the AllowSelection property to None this.gridGroupingControl1.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.None | Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend; } private void anyAllowSelection_CheckedChanged(object sender, EventArgs e) { //Sets the AllowSelection property to Any this.gridGroupingControl1.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any; }
VB
Private Sub noneAllowSelection_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles noneAllowSelection.CheckedChanged 'Sets the AllowSelection property to None Me.gridGroupingControl1.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.None Or Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend End Sub Private Sub anyAllowSelection_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles anyAllowSelection.CheckedChanged 'Sets the AllowSelection property to Any Me.gridGroupingControl1.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any End Sub
This is applicable for GridControl and GridDataBoundGrid also.
Screenshot
The following image illustrates the Selection Backcolor as a Default Selection Backcolor.
Samples: