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.
Unfortunately, activation email could not send to your email. Please try again.

using a RadioButton or a CheckBox in a GridControl Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

53773 Dec 20,2006 03:43 AM Dec 20,2006 07:34 AM Windows Forms 5
loading
Tags: GridControl
Mohamed
Asked On December 20, 2006 03:43 AM

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.

Administrator [Syncfusion]
Replied On December 20, 2006 04:14 AM

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

Administrator [Syncfusion]
Replied On December 20, 2006 04:17 AM

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

Administrator [Syncfusion]
Replied On December 20, 2006 04:53 AM

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

Administrator [Syncfusion]
Replied On December 20, 2006 06:06 AM

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

Administrator [Syncfusion]
Replied On December 20, 2006 07:34 AM

It works fine!
Thank you very much!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;