Home Forums WinForms controls Xceed Grid for WinForms Showing RadioButton in Particular Column Reply To: Showing RadioButton in Particular Column

User (Old forums)
Member
Post count: 23064

Andre answered you through support, here is the answer again 🙂

You need to use the CellEditorManager class, and rap a RadioButton through it, and it should work fine :

private void Form1_Load(object sender, System.EventArgs e)
{
//gridControl1.SingleClickEdit = true;

RadioButton radio = new RadioButton();
radio.AutoCheck = false;

gridControl1.Columns[ 0 ].CellEditorManager = new Xceed.Grid.Editors.CellEditorManager( radio, “Checked”, true, true );
gridControl1.Columns[ 0 ].CellViewerManager = new CellViewerManager( radio, “Checked” );

gridControl1.Columns[ 0 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager_ActivatingControl);
gridControl1.Columns[ 0 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager_DeactivatingControl);

for( int i = 0; i < 5; i++ )
{
Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
row.EndEdit();
}
}

private void CellEditorManager_ActivatingControl(object sender, CellEditorEventArgs e)
{
System.Diagnostics.Debug.WriteLine( “in activating” );
( ( RadioButton )e.Control).Click += new EventHandler(Form1_Click);
}

private void CellEditorManager_DeactivatingControl(object sender, CellEditorEventArgs e)
{
System.Diagnostics.Debug.WriteLine( “in deactivating” );
( ( RadioButton )e.Control).Click -= new EventHandler(Form1_Click);
}

private void Form1_Click(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine( sender.ToString() );
( ( RadioButton )sender).Checked = !( ( RadioButton )sender).Checked;
}

Imported from legacy forums. Posted by Matt (had 2985 views)