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
Haha :D. I knew there was something easier, I just couldn't find it. Thanks Mike.
column.Band.Layout.Grid
This actually returns an UltraGridBase, but you can cast it to an UltraGrid.
Well I got something through reflection. It is not pretty, but it works. if there is an easier way, let me know.
code:
Private Function GetGridFromColumn(column As UltraGridColumn) As UltraGrid Dim grid As UltraGrid = Nothing Dim propEditorOwnerInfo = column.GetType().GetProperty("EditorOwnerInfo", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance) Dim typeEmbeddableOwnerInfo = System.Reflection.Assembly.GetAssembly(GetType(UltraGridColumn)).GetType("Infragistics.Win.UltraWinGrid.EmbeddableEditorOwnerInfo", False, True) If (propEditorOwnerInfo IsNot Nothing AndAlso typeEmbeddableOwnerInfo IsNot Nothing) Then Dim cast = Convert.ChangeType(propEditorOwnerInfo.GetValue(column, Nothing), typeEmbeddableOwnerInfo) Dim propGrid = typeEmbeddableOwnerInfo.GetProperty("Grid", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance) If (propGrid IsNot Nothing) Then grid = TryCast(propGrid.GetValue(cast, Nothing), UltraGrid) End If End If Return grid End Function
Another, it is related, question. Let say I get an UltraGridColumn as an argument, is there any way the check if this column is associated to a ultraWinGrid? if so, how could I get the associated grid from that argument?
Thanks Mike!!! That fixed the problem :D