Home Forums WinForms controls Xceed Grid for WinForms IBindingList, CollectionBase, and comboboxes Reply To: IBindingList, CollectionBase, and comboboxes

Xceed Support
Member
Post count: 5658

The ActivatingControl event will only be triggered when the cell will get in “Edit mode”. If you want to change the value of the cell (from the “ExtraOption” column), you can directly assign the Value property of the cell. Also, to assign the selected value to the cell (when the Editor is left), you need to assign the DisplayMember property the right column from the ComboBoxEditor (in this case, ExtraOption).

Here is a simple example on how to have a column of an Enum type with a ComboBox showing the choices:

//Sample code:
enum months : int
{
  January,
  February,
  March,
  April,
  May,
  June,
  July,
  August,
  September,
  October,
  November,
  December
};

private void Form1_Load( object sender, EventArgs e )
{
  Column col1 = new Column( “Items Column” );
  Column col2 = new Column( “Enum Column”, typeof( months ) );
  gridControl1.Columns.Add( col1 );
  gridControl1.Columns.Add( col2 );

  for( int i = 0; i < 20; i++ )
  {
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    row.Cells[ 0 ].Value = “Item ” + i.ToString();
    row.Cells[ 1 ].Value = ( months )( i % 12 );

    row.EndEdit();
  }

  ComboBoxEditor comboBoxEditor1 = new ComboBoxEditor();
  Array value = System.Enum.GetValues( typeof( months ) );
  for( int i = 0; i < value.Length; i++ )
  {
    comboBoxEditor1.Items.Add( value.GetValue( i ) );
  }
  comboBoxEditor1.ValueMember = “Column1”;

  gridControl1.Columns[ 1 ].CellEditorManager = comboBoxEditor1;
}

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