Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
340
DropDownEditorButton - Call to DropDown() doesn't show drop down window
posted

Hi,

I have made a custom column that consists out of an EditorWithText editor and a DropDownEditorButton as one of its editorbuttons. When the editorbutton is clicked, an UltraGrid is opened. This is done so I can make use of the filterrow.

Everything works fine. But now I want to open the grid when the control gets into to edit mode, either by tabbing into it or by clicking it.

As you can see in the code(below) I've added a handler to the editor's AfterEnterEditMode.  In the handler, I make the call to the DropDownEditorButton's Dropdown() method. The handler I placed on the dropDownbutton's BeforeDropDown event is called, so the DropDown method did something, but after that nothing happens. No Grid, no nothing. But when I click on the dropdown button, I do see a grid.

I have seen multiple post where people have this problem and the solution there was to cast the active cell's EditorResolved of the grid to EmbeddableEditorButtonBase. Then cast the EmbeddableEditorButtonBase's editorbutton to an DropDownEditorButton and call DropDown(). But this does not work for me.

Are there any other suggestions?

Code:

        _grid = New ePosDataGrid()
        _grid.Height = 300
        _grid.HasFilterRow = True
        _grid.DisplayColumns = Me.DisplayColumns
        _grid.DataSource = Me.DataSource
        _grid.Base.DisplayLayout.Override.FilterEvaluationTrigger = FilterEvaluationTrigger.OnCellValueChange
 
        _dropDownButton = New DropDownEditorButton() With {.Control = _grid}
        _dropDownButton.Key = "CustomActivityDropDownButton"
 
        AddHandler _dropDownButton.AfterCloseUp, AddressOf dropDownButton_AfterCloseUp
        AddHandler _dropDownButton.BeforeDropDown, AddressOf dropDownButton_BeforeDropDown
 
        Dim editor As New EditorWithText(New DefaultEditorOwner())
        AddHandler editor.AfterEnterEditMode, AddressOf editor_AfterEnterEditMode
 
        column.Editor = editor
 Private Sub editor_AfterEnterEditMode(sender As Object, e As EventArgs)
        _dropDownButton.DropDown()
    End Sub
Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    I tried this out using your code and I got the same results. The drodpown is actually dropping down, but then it closes up again almost instantly. This is probably a timing issue. The cell enters edit mode, you drop down the list, and then the cell displays a TextBox over itself and focuses the TextBox which pulls focus from the dropdown and closes it.

    To get around this, you have to create a delay so that the cell can finish it's own processing before dropping down the list. This worked for me:

        Private Sub editor_AfterEnterEditMode(sender As Object, e As EventArgs)
            Me.UltraGrid1.BeginInvoke(New MethodInvoker(AddressOf Me.ShowDropDown))
        End Sub

        Public Sub ShowDropDown()
            Dim editor As EmbeddableEditorButtonBase = Me.UltraGrid1.ActiveCell.EditorResolved
            Dim dropDownEditorButton As DropDownEditorButton = editor.ButtonsRight(0)
            dropDownEditorButton.DropDown()
        End Sub

Reply Children