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
460
call DropDown() of DropDownEditorButton
posted

I'm using an UltraComboEditor as my EditorComponent for a particular column in my UltraGrid,

I added a DropDownEditorButton to the ButtonsRight collection of the UltraComboEditor

(the control the DropDownEditor is associated to, happens to be is an UltraGrid, but I don't think it should matter)

I'd like when the user clicks on the text area of the cell of that particular column, i'd like the the DropDownEditor should drop down.

I tried running this line of code in the grid.CellClick or grid.AfterEnterEditMode or grid.DoubleClickRow

DirectCast(grid.ActiveCell.EditorComponentResolved,UltraComboEditor).ButtonsRight("myBotton").DropDown()

and it keeps throwing this exception:

The associated editor must be in edit mode to be dropped down

I tried preceding any of the following:

grid.PerformAction(EnterEditMode)

or

grid.ActiveCell.EditorResolved.Focus()

or

grid.ActiveCell.EditorComponentResolved.Focus

same result

 

any advice would be greatly apprciated

 

Mendel

  • 469350
    Verified Answer
    Offline posted

    Hi,

    The problem with that you are doing here is this line of code:

    mendel_lowy said:
    DirectCast(grid.ActiveCell.EditorComponentResolved,UltraComboEditor).ButtonsRight("myBotton")

    This code is trying to drop down the button on the EditorComponentResolved, which in this case is the UltraComboEditor control on the form, not the cell in the grid.The UltraCombo control on the form is not in edit mode - the grid cell is. The grid does not use the control you assign to the EditorComponent property. What happens is that the editor component (the UltraComboEditor) provides a copy of it's internal editor to the grid.

    The correct way to do this would be something like this:


        Private Sub UltraGrid1_AfterEnterEditMode(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraGrid1.AfterEnterEditMode
            ' Get the grid
            Dim grid As UltraGrid = DirectCast(sender, UltraGrid)

            ' Get the editor from the ActiveCell. Note the use of EditorResolved, not EditorComponentResolved.
            Dim editor As EmbeddableEditorButtonBase = DirectCast(grid.ActiveCell.EditorResolved, EmbeddableEditorButtonBase)

            ' We could also use EditorWithCombo, if we wanted, but EmbeddableEditorButtonBase is the base
            ' type for all editors that support editor buttons.
            '
            'Dim editor As EditorWithCombo = DirectCast(grid.ActiveCell.EditorResolved, EditorWithCombo)

            ' Get the dropdown button
            Dim dropdownButton As DropDownEditorButton = DirectCast(editor.ButtonsRight("myButton"), DropDownEditorButton)

            ' Drop it down.
            dropdownButton.DropDown()

        End Sub

    You will need to add some other checks to this code, like checking for the correct column(s) and checking if the ActiveCell is Nothing, but you this is the basic gist of it.

     

     

     

  • 48586
    Suggested Answer
    posted

    Hello ,

     

    If you want to display a UltraGrid as DropDown of column’s editor I suggest you to use UltraCombo instead. If I am understand you correctly there is no need to add  an editor button in ButtonRights collection. Base on description of your scenario I have created a small sample to achieve your goal. Please run the sample and let me know if this is what you are looking for.

     

    I am waiting for your response.

    WinGridDropDownVB.zip