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

Grid Control: Doubt

Hi All,

I am using Syncfusion Grid control. I have to use radio button in a column. I referred the examples and tried using “StringCollection” function. Now I have to create choicelist related to column. The users will be provided with a list of option in a column as shown in the attached screen. They have to select one radio button in that column. The cellvalue of the grid must be retrieved from the database. Please clarify me how to create column wise choicelist.


Thanks in advance,
Pavith


Sample Screen.zip

6 Replies

AD Administrator Syncfusion Team September 26, 2006 08:56 AM UTC

Hi Pavithira,

You can get the desired behavior, by handling the CurrentCellChanged Event of the grid and try to set the cellvalue for other cells in the column to 1.

Here is a sample demonstrating this behavior
http://www.syncfusion.com/Support/user/uploads/RadioColumnOptions_e0dce7ac.zip

If I did not answer your question, please explain a little more about what you want, and I’ll try again.

Best Regards,
Haneef


PA Pavithira September 26, 2006 09:13 AM UTC

Hi Haneef,

Thanks for your help.

I am having another doubt. If i click one radio button and unclick it, then it is working. But if i try to click the same button second time it is not working in the given sample. Please help me.

I am working in .Net2003. If u have any sample in .Net2003, please sent it to me.

Thanks,
Pavithira S

>Hi Pavithira,

You can get the desired behavior, by handling the CurrentCellChanged Event of the grid and try to set the cellvalue for other cells in the column to 1.

Here is a sample demonstrating this behavior
http://www.syncfusion.com/Support/user/uploads/RadioColumnOptions_e0dce7ac.zip'>http://www.syncfusion.com/Support/user/uploads/RadioColumnOptions_e0dce7ac.zip''>http://www.syncfusion.com/Support/user/uploads/RadioColumnOptions_e0dce7ac.zip

If I did not answer your question, please explain a little more about what you want, and I’ll try again.

Best Regards,
Haneef


AD Administrator Syncfusion Team September 26, 2006 09:54 AM UTC

Hi Pavithira,

Try this code snippet to resolve this.

int tristate = -1;
private void gridControl1_CurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if(cc.Renderer.StyleInfo.CellType == "RadioButton")
{
if(cc.Renderer.StyleInfo.CellValue.ToString() == "0")
{

int SelectedRowIndex = int.Parse(this.hs[cc.ColIndex].ToString());
if( SelectedRowIndex == cc.RowIndex)
this.gridControl1[cc.RowIndex,cc.ColIndex].CellValue = tristate = (tristate == 1)?0:1;
else
{
this.gridControl1[(int)(this.hs[cc.ColIndex]),cc.ColIndex].CellValue =1;
tristate = -1;
}
this.hs[cc.ColIndex] = cc.RowIndex;
}
}
}

.Net 2003 Sample: http://www.syncfusion.com/Support/user/uploads/RadioColumnOption_2d0c601c.zip

Let me know if this helps.

Thanks,
Haneef


AD Administrator Syncfusion Team September 28, 2006 09:22 AM UTC

Hi Haneef,

I need one more help. All are working fine. But if i set one radio button cell value as "0" during load event. Then if i try to click other one the previous one is also set to "0" that is both buttons are enabled.
Also i need one more clarification. I have attached a screen shot. Please have a look at it. The rows without radio button are filled with the number "1". I need to avoid that too. Please help me in this regard too.


Thanks,
Pavithira s


Sample Screen Shot.zip


AD Administrator Syncfusion Team September 28, 2006 12:20 PM UTC

Hi Pavithira,

You can handle the SaveCellInfo event and set the RowIndex of the selected radio button column. Below is a code snippet.

private void gridSaveCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridSaveCellInfoEventArgs e)
{
if(e.Style.CellType == "RadioButton" && IsLoad)
{
if( e.Style.CellValue.ToString() == "0" )
{
int SelectedRowIndex = int.Parse(this.hs[e.ColIndex].ToString());
if( SelectedRowIndex != e.RowIndex )
hs[e.ColIndex] = e.RowIndex;
}
}
}

bool IsLoad =true;
private void gridControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{IsLoad = false;}

Sample : http://www.syncfusion.com/Support/user/uploads/RadioColumnOption_22b3e92.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team September 30, 2006 09:51 AM UTC

Thanks a lot Haneef. That worked fine :)

Loader.
Live Chat Icon For mobile
Up arrow icon