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
close icon

Radio Buttons

Hi all,

I want RadioButton celltype in vertical orientation in Sync Fusion GridControl. By default it is Horizontal.

Thanks in Advance.

1 Reply

HA haneefm Syncfusion Team July 23, 2007 03:17 PM UTC

Hi Shuvendu,

There is no built-in support for this.To need this support, You would have to derive the RadioButtonCellRenderer and override this method to create the Custom Celltypes.

protected override System.Drawing.Rectangle OnLayout(int rowIndex, int colIndex, Syncfusion.Windows.Forms.Grid.GridStyleInfo style, System.Drawing.Rectangle innerBounds, System.Drawing.Rectangle[] buttonsBounds)
{
Rectangle clientRectangle = GridMargins.RemoveMargins(innerBounds, style.TextMargins.ToMargins());
StringCollection buttonInfos = style.ChoiceList;
int count = buttonInfos != null ? buttonInfos.Count : 0;
if (buttonInfos != null && count > 0)
{
int width = clientRectangle.Width ;
int height = clientRectangle.Height/count;
if (height == 0)
height = clientRectangle.Height;
GridVerticalAlignment verticalAlign = style.VerticalAlignment;
int yOffset = clientRectangle.Top;
if (verticalAlign == GridVerticalAlignment.Middle)
yOffset += (clientRectangle.Height - height)/2;
else if (verticalAlign == GridVerticalAlignment.Bottom)
yOffset += (clientRectangle.Height - height);
int xOffset = clientRectangle.Left;
for (int n = 0; n < count; n++)
{
Rectangle bounds = new Rectangle(xOffset, yOffset, width, height);
buttonsBounds[n] = bounds;
if(buttonInfos != null)
{
((GridRadioButton)GetButton(n)).Enabled = this.GetButtonInfo(n, style).Enabled;
}
yOffset += height;
}
}
clientRectangle.Width = 0;
return clientRectangle;
}

A custom CellType can be created, it requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. This sample in \Syncfusion\Essential Studio\4.1.0.10\windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial can be referred.

After creating the custom celltype, it has to be registered through CellModels.Add

this.gridControl1.CellModels.Add("MyRadioButton", new MyRadioButtonCellModel(this.gridControl1.Model));

Please take a look at the sample for more details.
RadioButton.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon