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()
grid.ActiveCell.EditorComponentResolved.Focus
same result
any advice would be greatly apprciated
Mendel
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.
Yes, issue resolved, Thanks!