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. Image for the cookie policy date

Checkbox appearance in GridControl

Hi,

On a Desktop application (NET 3.5) we have a GridControl and on certain cells we are showing a Checkbox. We've seen on some samples that the indeterminate/tristate state is shown as box with a filled square in it, but we haven't been able to set this appearance.

"Interactive Cell" sample in Grid Control:


The appearance we get is always this one:


How can we customize or set the tristate appearance to the one of the sample?

Kind regards... Boris

5 Replies

MG Mohanraj Gunasekaran Syncfusion Team May 4, 2017 02:27 PM UTC

Hi Boris, 
 
Thanks for using Syncfusion products. 
 
 
Query 
Solution 
We've seen on some samples that the indeterminate/tristate state is shown as box with a filled square in it, but we haven't been able to set this appearance. 
Solution1 
In order to use tristate appearance for CheckBox, you can use the TriState property in QueryCellInfo event. Please refer to the below code example and the attached sample, 
 
Code example 
this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo; 
 
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    if (e.Style.CellIdentity.ColIndex == 5 && e.Style.CellIdentity.RowIndex > 0) 
    { 
        e.Style.CellType = GridCellTypeName.CheckBox; 
        e.Style.TriState = true; 
        //Used to set the checked, unchecked and intermediate value for checkbox value 
        e.Style.CheckBoxOptions = new GridCheckBoxCellInfo("1", "0", "", true); 
    } 
} 
 
 
Solution2 
Also, you can achieve your scenario by using the below code example, 
 
Code example 
this.gridControl1[2, 5].CellType = GridCellTypeName.CheckBox; 
this.gridControl1[2, 5].TriState = true; 
this.gridControl1[2, 5]. CheckBoxOptions = new GridCheckBoxCellInfo("1", "0", "", true); 
 
 
 
 
Sample link: GridControl 
 
Screenshot 
 
 
 
Please refer the below UG and KB link to use the CheckBoxOptions property, 
 
 
Regards, 
Mohanraj G 



BM Boris Mouzo Izquierdo May 4, 2017 02:37 PM UTC

Hi,

To set or use the tristate is not the issue as we've already implemented it and it works fine. The question is, how can we show the indeterminate state as a filled out square in the chekbox instead of a grayed out check. Right now we have three states:
  • Checked: Shows a Check in the box
  • Unchecked: Shows an empty box
  • Indeterminate: Shows a Check in a grayed out box, looks like as if the CheckBox control were disabled but isn't so.

What we'd like to know is what needs to be set or configured to show the square in the box instead like in the image you posted.

Kind regards... Boris



MG Mohanraj Gunasekaran Syncfusion Team May 5, 2017 06:19 AM UTC

Hi Boris, 

Sorry for the inconvenience caused. 

In order to show the square box for intermediate state in the CheckBox, enable the ThemesEnabled property for GridControl. Please refer to the below code example and the sample, 
 
Code example 
this.gridControl1.ThemesEnabled = true; 
 
Sample link: GridControl 
 
Regards, 
Mohanraj G  



BM Boris Mouzo Izquierdo May 5, 2017 07:39 AM UTC

Hi,

I thought I had tried that one, too, but now it works. Or maybe I discarded it because by setting that control property to True I was loosing the visual style I had defined for the headers. To avoid this, the following line needs to be added if you want to keep a custom visual style:

            Me.grdControl.BaseStylesMap.Item("Column Header").StyleInfo.Themed = False

Kind regards... Boris


MG Mohanraj Gunasekaran Syncfusion Team May 8, 2017 05:32 AM UTC

Hi Boris, 

Thanks for your update. 

You were right. If you would not like to change the header appearance when enable themes for grid, you can use Themed property to disable the themes settings. Please refer the below code example, 

Code example 
To avoid themes settings for Headers (RowHeader and ColumnHeader) 
Me.gridControl1.BaseStylesMap.Header.StyleInfo.Themed = False; 
                      (or) 
Me.gridControl1.BaseStylesMap.Item("Header").StyleInfo.Themed = False; 
 

To avoid the Themes settings for RowHeader 
Me.gridControl1.BaseStylesMap.RowHeader.StyleInfo.Themed = False; 
                      (or) 
Me.gridControl1.BaseStylesMap.Item("Row Header").StyleInfo.Themed = False; 
 

To avoid the Themes settings for ColumnHeader 
Me.gridControl1.BaseStylesMap.ColumnHeader.StyleInfo.Themed = False; 
                      (or) 
Me.gridControl1.BaseStylesMap.Item("Column Header").StyleInfo.Themed = False; 
 


Anyway, we are glad to know that your reported problem has resolved. Please let us know, if you have any further assistance.  

Regards, 
Mohanraj G 


Loader.
Up arrow icon