Home Forums WinForms controls Xceed Grid for WinForms Use checkbox column with Oracle data. Reply To: Use checkbox column with Oracle data.

Xceed Support
Member
Post count: 5658

To resolve the issue, you override CheckBoxEditor and CheckBoxViewer. Here is some snippet of the code:

<code>
//In the Form1_Load of the Grid
gridControl1.Columns[ “CheckBoxColumn” ].CellEditorManager = new MyCheckBoxEditor( new WinCheckBox(), true, true );
gridControl1.Columns[ “CheckBoxColumn” ].CellViewerManager = new MyCheckBoxViewer( new WinCheckBox(), “Checked” );
//Load the data
this.shippersTableAdapter.Fill( “YourOracleDataBase” );

//In MyCheckBoxEditor.cs
class MyCheckBoxEditor : CellEditorManager
{
public MyCheckBoxEditor( WinCheckBox template, bool inPlace, bool handleActivationClick )
: base( template, inPlace, handleActivationClick )
{
}

protected override CreateControlMode CreateControlMode
{
get
{
return CreateControlMode.ClonedInstance;
}
}

protected override System.Windows.Forms.Control CreateControl()
{
return ThemedControl.CloneControl( this.TemplateControl );
}

protected override void SetControlValueCore( System.Windows.Forms.Control control, Cell cell )
{
( ( WinCheckBox )control).Checked = cell.Value.ToString() == “Y”;
}

protected override object GetControlValueCore( System.Windows.Forms.Control control, Cell cell, Type returnDataType )
{
if( ( ( WinCheckBox )control ).Checked )
{
return “Y”;
}
else
{
return “N”;
}
}
}

//In MyCheckBoxViewer.cs
class MyCheckBoxViewer : CellViewerManager
{
public MyCheckBoxViewer( WinCheckBox template, string propertyName )
: base( template, propertyName )
{
}

protected override void SetControlValueCore( Xceed.Grid.Cell cell )
{
( ( WinCheckBox )this.Control ).Checked = cell.Value.ToString() == “Y”;
}
}
</code>

Imported from legacy forums. Posted by CharlesB (had 279 views)