)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent the blackout selection when AllowSelection is set to None or Any in WinForms GridControl, GridGroupingControl and GridDataBoundGrid?

Platform: WinForms |
Control: GridControl |
Published Date: May 23, 2015 |
Last Revised Date: February 11, 2020
Tags: selection

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.

Show the backcolor while changing AllowSelection from Any to None

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

 

Note:

This is applicable for GridControl and GridDataBoundGrid also.

Screenshot

The following image illustrates the Selection Backcolor as a Default Selection Backcolor.

Show the backcolor while changing AllowSelection from Any to None

Samples:

C#: Selection_Backcolor_CS

VB: Selection_Backcolor_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon