Home Forums WinForms controls Xceed Grid for WinForms Change ComboBoxEditor width on Column Width change.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #14962 |

    How do I get the Combobox Editor dropdown width to match the Column width of the parent column?

    I have the Column1_WidthChanged event trapped, it fires, the new width is set and I call all sorts of code to try and get the size to match, but with no luck.

    Column1 As Xceed.Grid.Column
    ComboBoxEditor1 As Xceed.Grid.Editors.ComboBoxEditor

    Private Sub Column1_WidthChanged(ByVal…) Handles Column1.WidthChanged
    Dim t_WinCbo As Xceed.Editors.WinComboBox = Column1.CellEditorManager.TemplateControl
    t_WinCbo.DropDownSize = New Size(Column1.Width, 200)
    t_WinCbo.DropDownMaxSize = New Size(Column1.Width, 100)
    t_WinCbo.DropDownControl.Size = New Size(Column1.Width, 100)
    t_WinCbo.DropDownResizable = False

    ComboBoxEditor1.TemplateControl.DropDownSize = New Size(Column1.Width, ComboBoxEditor1.TemplateControl.DropDownSize.Height)
    end Sub

    — None of the above approaches have any effect, but in the intialize call, I can set the size with;
    Me.ComboBoxEditor1.TemplateControl.DropDownControl.Size = New System.Drawing.Size(100, 100)
    Me.ComboBoxEditor1.TemplateControl.Size = New System.Drawing.Size(100, 100)

    Imported from legacy forums. Posted by Rock (had 2444 views)

    User (Old forums)
    Post count: 23064

    This does not work because you are doing it on the template, which is taken into consideration only when first loading the grid. After that, you need to do it on the actual control itself that gets activated when the cell falls into edit mode.

    Therefore you need to subscribe to the SettingControlAppearance, and use e.Control in the event handler to set the width of the Dropdown. You need to cast the e.Control to a WinComboBox for this to work.

    e.g. :

    private void CellEditorManager_SettingControlAppearance(object sender, CellEditorEventArgs e)
    ( ( WinComboBox )e.Control).DropDownControl.Width = 100;

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

    User (Old forums)
    Post count: 23064


    After putting the handler in the form load event for the specific column(s), it worked well.

    Imported from legacy forums. Posted by Rock (had 3446 views)

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