Home Forums WinForms controls Xceed Grid for WinForms Property grid with drop down combobox – detect value changed? Reply To: Property grid with drop down combobox – detect value changed?

User (Old forums)
Member
Post count: 23064

You need to subscribe to ComboBox events through the ActivatingControl event of the CellEditorManager.  This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.

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 447 views)