Home Forums WinForms controls Xceed Grid for WinForms Update CellEditorManager on runtime

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16509 |

    Hi

    I’ve got a ComboBoxEditor in my GridControl which has to be updated at runtime.

    It’s defined as follows:

    Me.SalesmanagerColumn.CellEditorManager = Me.ComboBoxEditor1

    Later in the code i fill the ComboBoxEditor1 as follows:

    ComboBoxEditor1.Items.Add(…)

    This works the first time, but when i update the ComboBoxEditor1 later (add and remove items), the changes are not visible in the GridControl.
    How can i perform an update of all CellEditorManagers?

    Kind regards

    Imported from legacy forums. Posted by Peter (had 408 views)

    User (Old forums)
    Member
    Post count: 23064

    When assigning an editor to a CellEditorManager, you are setting a template which will be used when a cell of that column is entering edition.  Once this template is assigned to a CellEditorManager, any update to this template will not be taken into account by the grid.  This is why you need to update the live instance, and not the template, of the editor, as the cell enters edition.

    So to do this, you need to subscribe to the 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 Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        AddHandler GridControl1.Columns( 0 ).CellEditorManager.ActivatingControl, AddressOf CheckBoxEditor_ActivatingControl
        AddHandler GridControl1.Columns( 0 ).CellEditorManager.DeactivatingControl, AddressOf CheckBoxEditor_DeactivatingControl

      End Sub

    //Event handlers

      Private Sub CellEditorManager_ActivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )

        Dim editor as Xceed.Editors.WinComboBox = CType( e.Control, Xceed.Editors.WinComboBox )
        ‘Here you can add or remove items instead of (or in addition to) subscribing to events.
        editor.Items.add(…)
        AddHandler editor.SelectedIndexChanged, AddressOf editor_SelectedIndexChanged

      End Sub

      Private Sub CellEditorManager_DeactivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )
       
        Dim editor as Xceed.Editors.WinComboBox = CType( e.Control, Xceed.Editors.WinComboBox )
        ‘this needs to be done, if not, subscriptions will pill up every time the editor is activated
        RemoveHandler editor.SelectedIndexChanged, AddressOf editor_SelectedIndexChanged
     
      End Sub

      Private sub editor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As EventArgs )

        Dim index As String = “index ” + CType( sender, WinComboBox ).SelectedIndex.ToString()
        System.Diagnostics.Debug.WriteLine( index )
       
      End Sub

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.