Home Forums WinForms controls Xceed Grid for WinForms ComboBoxEditor AutocompleteMode and Null Value Reply To: ComboBoxEditor AutocompleteMode and Null Value

User (Old forums)
Member
Post count: 23064

You still need to use the ActivatingControl/DeactivatingControl events. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.  Then you subscribe to the ComboBox events in the ActivatingControl event handler.  The following code shows how to do this, you only need to cast your editor to the .NET ComboBox instead of the WinComboBox in the event handlers.

e.g.:

//at Form_Load

    private void Form1_Load(object sender, System.EventArgs e)
    {
      gridControl1.Columns[ “column6” ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorColumn6_ActivatingControl);
      gridControl1.Columns[ “column6” ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorColumn6_DeactivatingControl);
    }

//Event handlers

    private void CellEditorColumn6_ActivatingControl(object sender, CellEditorEventArgs e)
    {
      ( ( WinComboBox )e.Control).SelectedIndexChanged += new EventHandler(ComboBoxColumn6_SelectedIndexChanged);
    }

    private void CellEditorColumn6_DeactivatingControl(object sender, CellEditorEventArgs e)
    {
      //need to unsubscribe to the event, so it does not keep piling up in the ActivatingControl
      ( ( WinComboBox )e.Control).SelectedIndexChanged -= new EventHandler(ComboBoxColumn6_SelectedIndexChanged);
    }

    private void ComboBoxColumn6_SelectedIndexChanged(object sender, EventArgs e)
    {
      string index = “index ” + ( ( WinComboBox )sender).SelectedIndex.ToString();
      System.Diagnostics.Debug.WriteLine( index );
    }

Imported from legacy forums. Posted by André (had 1306 views)