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

using a RadioButton or a CheckBox in a GridControl Cell

Hi,
I'm having a problem to use a RadioButton within a Cell in a GridControl. I have not found any documentation about how to do it, for example the CellValueType for a RadioButton, wich properties I have to set? (for example, for a CheckBox it's CheckBoxOptions). By the way, if you can give me a sample about a RadioButton or a CheckBox it will help me a lot.
P.S. : I'm using 3.3.0.0 version
Thank you very much.

5 Replies

AD Administrator Syncfusion Team December 20, 2006 09:14 AM UTC

Hi Mohamed,

Regarding Radio Button CellType.

With the RadioButton CellType you can have a number of radiobuttons in a cell which, will behave as grouped. The number of radiobuttons that are needed is set to an instance of the StringCollection and are added through the ChoiceList property of that particular cell.And also you can set the CellValue of the radiobutton cell to the index of the StringCollection will enable the particular button as checked in a grid. Here is a code snippet.

this.gridControl1[2, 2].CellType = "RadioButton";

sc = new StringCollection();
sc.AddRange(new String[]{"radio 0/disabled","radio 1","radio 2"});
this.gridControl1[2, 2].ChoiceList = sc;

this.gridControl1[2, 2].CellValue = 1;//selected button

Also refer to the shipped RadioButton browser sample for more details.
[install drive]\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CellTypes\RadioButtonCells\cs

Regarding CheckBoxCellType:

Please refer to the following KnowledgeBase(KB) articles for more details.
What is the purpose of checkboxoptions property and how do I set it?
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=305

Best Regards,
Haneef


AD Administrator Syncfusion Team December 20, 2006 09:17 AM UTC

Hi Mohamed,

Regarding Radio Button CellType.

With the RadioButton CellType you can have a number of radiobuttons in a cell which, will behave as grouped. The number of radiobuttons that are needed is set to an instance of the StringCollection and are added through the ChoiceList property of that particular cell.And also you can set the CellValue of the radiobutton cell to the index of the StringCollection will enable the particular button as checked in a grid. Here is a code snippet.

this.gridControl1[2, 2].CellType = "RadioButton";

sc = new StringCollection();
sc.AddRange(new String[]{"radio 0/disabled","radio 1"});
this.gridControl1[2, 2].ChoiceList = sc;

this.gridControl1[2, 2].CellValue = 0;//selected button

Also refer to the shipped RadioButton browser sample for more details.
[install drive]\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CellTypes\RadioButtonCells\cs

Regarding CheckBoxCellType:

Please refer to the following KnowledgeBase(KB) articles for more details.
What is the purpose of checkboxoptions property and how do I set it?
How do I insert an unbound check box column in a GridDataBoundGrid?

Best Regards,
Haneef


AD Administrator Syncfusion Team December 20, 2006 09:53 AM UTC

Thank you Haneef for the answer.
I have another question, now i'm using a CheckBox instead of a RadioButton.
I am using the CheckBoxClick event of a GridControl , i'm trying to get the state of the Check box using the Renderer of the CurrentCell and i'm using the CellValue property to get the boolean that determines the state of my chack box (checked or unchecked) there is an example :
GridCheckBoxCellRenderer checkBoxRenderer = (GridCheckBoxCellRenderer)this.gridControl.CurrentCell.Renderer; bool test = (bool) checkBoxRenderer.CurrentStyle.CellValue;

i have many CheckBox controls in my column, but when i check one of them my boolean test is true, and when i check another one the boolean is false, so i can't know if my CheckBox is checked or not. Is there a problem with the event that i use?
i don't know if my explanation is clear enough.

Thanks


AD Administrator Syncfusion Team December 20, 2006 11:06 AM UTC

Hi,

You can handle the CurrentCellChanged event of the grid and access the checkbox cell value using CellValue property. Here is a code snippet to show this.

private void grid_CurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;
GridStyleInfo style = this.grid.Model[cc.RowIndex,cc.ColIndex];
if( style.CellType == "CheckBox" )
{
bool b = (bool)style.CellValue ;
Console.WriteLine("Cell[{0},{1}] = {2} ",cc.RowIndex,cc.ColIndex,b);
}
}

Best Regards,
Haneef


AD Administrator Syncfusion Team December 20, 2006 12:34 PM UTC

It works fine!
Thank you very much!

Loader.
Live Chat Icon For mobile
Up arrow icon