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.

Grid Control: Doubt

Thread ID:

Created:

Updated:

Platform:

Replies:

49743 Sep 26,2006 02:03 AM Sep 30,2006 05:51 AM Windows Forms 6
loading
Tags: GridControl
Pavithira
Asked On September 26, 2006 02:03 AM

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

Administrator [Syncfusion]
Replied On September 26, 2006 04:56 AM

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

Pavithira
Replied On September 26, 2006 05:13 AM

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

Administrator [Syncfusion]
Replied On September 26, 2006 05:54 AM

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

Administrator [Syncfusion]
Replied On September 28, 2006 05:22 AM

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

Administrator [Syncfusion]
Replied On September 28, 2006 08:20 AM

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

Administrator [Syncfusion]
Replied On September 30, 2006 05:51 AM

Thanks a lot Haneef. That worked fine :)

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.

;