Home Forums WinForms controls Xceed Grid for WinForms use customcomboDropdown in Grid cell editor Reply To: use customcomboDropdown in Grid cell editor

Xceed Support
Member
Post count: 5658

You need to instantiate the CellEditorManager with the new CustomComboDropDown.

Here is the code I used (it will get a CustomComboDropDown in every cell of the second column):

The code from the Load_Form:

<code>
private void Form1_Load( object sender, EventArgs e )
{
Column col1 = new Column( “Column1” );
Column col2 = new Column( “Column2” );
gridControl1.Columns.Add( col1 );
gridControl1.Columns.Add( col2 );

CustomComboDropDown ccdd = new CustomComboDropDown( EnhancedBorderStyle.None );

gridControl1.Columns[ “Column2” ].CellEditorManager = new CellEditorManager( ccdd,
“Text”, true, true );

for( int i = 0; i < 20; i++ )
{
Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
row.Cells[ 0 ].Value = “Item ” + i.ToString();
row.EndEdit();
}
}
</code>

The code from the CustomComboDropDown class:

<code>
public class CustomComboDropDown : WinComboBox
{
public CustomComboDropDown()
: base()
{
StartMethod();
}

protected CustomComboDropDown( CustomComboDropDown template )
: base( template )
{
StartMethod();
}

public CustomComboDropDown( EnhancedBorderStyle ebs )
: base( ebs )
{
StartMethod();
}

private void StartMethod()
{
this.DataSource = this.FillData().Tables[ 0 ];

this.DropDownControl.FixedHeaderRows.Add( new GroupByRow() );
this.DropDownControl.FixedHeaderRows.Add( new ColumnManagerRow() );

Group groupShipCountry = new Group( “ShipCountry” );
groupShipCountry.Collapsed = true;
this.DropDownControl.GroupTemplates.Add( groupShipCountry );

Group groupShipCity = new Group( “ShipCity” );
groupShipCity.Collapsed = true;
this.DropDownControl.GroupTemplates.Add( groupShipCity );

this.DropDownControl.UpdateGrouping();

this.DropDownSize = new System.Drawing.Size( 500, 250 );
this.DropDownControl.ScrollBars = GridScrollBars.ForcedHorizontal;
this.DropDownControl.RowSelectorPane.Visible = true;

this.Location = new System.Drawing.Point( 10, 10 );
}

private DataSet FillData()
{
OleDbConnection connection = new OleDbConnection( “NorthwindConnectionString” );
connection.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter( “SELECT * FROM ORDERS”, connection );
DataSet data = new DataSet();
dataAdapter.Fill( data );
connection.Close();

return data;
}
}
</code>

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