Article information
Article relates to
RadGridView for WinForms, Q1 2012 SP1
Created by
Nikolay Diyanov
Last modified
May 23, 2012
Last modified by
Nikolay Diyanov, Telerik
public
class
RadioButtonCellElement : GridDataCellElement
{
RadioButtonCellElement(GridViewColumn column, GridRowElement row)
:
base
(column, row)
}
protected
override
void
CreateChildElements()
.CreateChildElements();
radioButtonElement1 =
new
RadRadioButtonElement();
radioButtonElement1.Margin =
Padding(0, 2, 0, 0);
radioButtonElement1.MinSize =
Size(50, 20);
radioButtonElement1.Text =
"Red"
;
radioButtonElement2 =
radioButtonElement2.Margin =
radioButtonElement2.MinSize =
radioButtonElement2.Text =
"Blue"
radioButtonElement3 =
radioButtonElement3.Margin =
radioButtonElement3.MinSize =
radioButtonElement3.Text =
"Green"
this
.Children.Add(radioButtonElement1);
.Children.Add(radioButtonElement2);
.Children.Add(radioButtonElement3);
radioButtonElement1.MouseDown +=
MouseEventHandler(radioButtonElement1_MouseDown);
radioButtonElement2.MouseDown +=
MouseEventHandler(radioButtonElement2_MouseDown);
radioButtonElement3.MouseDown +=
MouseEventHandler(radioButtonElement3_MouseDown);
Initialize(GridViewColumn column, GridRowElement row)
.Initialize(column, row);
((RadioPrimitive)radioButtonElement1.Children[1].Children[1].Children[0]).BackColor2 = Color.Red;
((RadioPrimitive)radioButtonElement2.Children[1].Children[1].Children[0]).BackColor2 = Color.Blue;
((RadioPrimitive)radioButtonElement3.Children[1].Children[1].Children[0]).BackColor2 = Color.Green;
radioButtonElement1_MouseDown(
object
sender, System.Windows.Forms.MouseEventArgs e)
.Value = 0;
radioButtonElement2_MouseDown(
.Value = 1;
radioButtonElement3_MouseDown(
.Value = 2;
SizeF ArrangeOverride(SizeF finalSize)
if
(
.Children.Count == 3)
.Children[0].Arrange(
RectangleF(0, 0, 50, 20));
.Children[1].Arrange(
RectangleF(55, 0, 50, 20));
.Children[2].Arrange(
RectangleF(110, 0, 50, 20));
return
finalSize;
DisposeManagedResources()
radioButtonElement1.MouseDown -=
radioButtonElement2.MouseDown -=
radioButtonElement3.MouseDown -=
.DisposeManagedResources();
SetContentCore(
value)
.Value !=
null
&&
.Value != DBNull.Value)
for
int
i = 0; i <
.Children.Count; i++)
((RadRadioButtonElement)
.Children[i]).ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off;
switch
.Parse(((GridDataCellElement)
).Value.ToString()))
case
0:
.Children[0]).ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
break
1:
.Children[1]).ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
2:
.Children[2]).ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
RadioButtonColumn: GridViewDataColumn
RadioButtonColumn(
string
fieldName)
(fieldName)
Type GetCellType(GridViewRowInfo row)
(row
is
GridViewDataRowInfo)
typeof
(RadioButtonCellElement);
.GetCellType(row);
RadioButtonColumn column =
"FavouriteColor"
);
column.HeaderText =
"Favourite Color"
column.Width = 170;
column.ReadOnly =
true
.radGridView1.Columns.Add(column);
Solutions in both CSharp and VB.NET are provided below.
Resources Buy Try