Hi.
I have an UltraCombo that is assigned to a grid cell EditorControl. Everything works as planned, except for one thing: The UltraCombo grid column does not auto size to the drop down.
I have tried setting the relevant AutoSize on the column and AutoFitStyle on the control without luck.
What am I missing here?
Best regards,
Goran
Hi Goran,
I don't understand what you are asking. Why would the column in the grid size itself to the dropdown? That does not make sense. The dropdown shows multiple columns and there is no relation between those columns and their widths and the grid column width.
The UltraCombo shows ONE column as I want to display it as 'normal' drop down. This column should span the entire width of the UltraCombo, otherwise it looks strange (when selecting items, the selection is cropped at the column border). No matter what I do, I cant accomplish this.
So I am not trying to resize the main grid column, I am trying to resize the drop down grid column.
Any suggestions?
hedge58 said:As I understand it, the UltraDropDown does not support Suggest functionality when used as EditorControl. So thats why I use the UltraCombo.
Okay, that's correct.
hedge58 said:Now if I only could find a place to read the width of the drop down button, I would be all set...
The width of the button is not expose via any property, but I'm pretty sure it's a constant, so you could just hard-code a value.
Or, you could try to get it from the UIElement. This will only work if the button is visible on the screen, but that should not be a problem - I can't think of a case where BeforeCellListDropDown could fire when the button is not visible.
So you can get the ActiveCell in the grid and call GetUIElement on it, then use GetDescendant on that to get the button element and use it's Rect to determine the width.
Mike,
could you provide a small code example for what you described above? I too need to get the drop down button widths.
it seems to be different for grids and controls so if I can grab the actual value that would be preferred.
Here is a small code example of how I did it:
Private Sub myGrid_BeforeCellListDropDown(ByVal sender As Object, _ ByVal e As CancelableCellEventArgs) _ Handles myGrid.BeforeCellListDropDown
Dim tmpDD As StandardDropDown 'This is actually an UltraComboDim btnWidth As Integer = 20Dim buttonElem As UIElementDim editorElem As EditorWithComboUIElementDim comboElem As EditorWithComboDropDownButtonUIElement'Get ref to dropdowntmpDD = CType(e.Cell.EditorComponentResolved, StandardDropDown) Try 'Get UIElement from cell buttonElem = e.Cell.GetUIElement() 'Get main editor element editorElem = CType(buttonElem.ChildElements(0), EditorWithComboUIElement) 'Get actual editor (UltraCombo) element
comboElem = CType(editorElem.ChildElements(0), EditorWithComboDropDownButtonUIElement) 'Set button width to with of editor button width btnWidth = comboElem.Rect.Width + DROPDOWNBUTTON_WIDTH_COMP 'const to adjust width, it misses by a few pixels for some reason Catch Throw End Try If tmpDD IsNot Nothing Then 'Adjust with of grid column in drop down tmpDD.DisplayLayout.Bands(0).Columns("Name").Width = e.Cell.Column.CellSizeResolved.Width - btnWidth End If
End Sub
Thanks for the code example! I had to convert to C# though, as this project is using it (see below).
Also, I didn't know how to convert your Ctype methods above, so I just used a foreach loop, i'm sure there is something more elegant, but its probably doing the same thing anyway.
also, my situation was a little different, we put this code in all of our drop down controls (in grids and on forms) on the "BeforeDropDown" event, so we really don't have a handle to the UltraGrid, but the UIElement was available for us to use.
Infragistics.Win.EditorWithComboUIElement editorElement = null; Infragistics.Win.EditorWithComboDropDownButtonUIElement comboElement = null; Infragistics.Win.EditorWithTextUIElement text = null; try { foreach (var element in UIElement.ChildElements) { if (element is Infragistics.Win.EditorWithComboUIElement) editorElement = (Infragistics.Win.EditorWithComboUIElement)element; } if (editorElement != null) { foreach (var element in editorElement.ChildElements) { if (element is Infragistics.Win.EditorWithComboDropDownButtonUIElement) comboElement = (Infragistics.Win.EditorWithComboDropDownButtonUIElement)element; if (element is Infragistics.Win.EditorWithTextUIElement) text = (Infragistics.Win.EditorWithTextUIElement)element; } if (comboElement != null) buttonWidth = comboElement.Rect.Width; } } catch (Exception) { }
CType is "Convert to type". It's just like casting in C#.
So:
editorElem = CType(buttonElem.ChildElements(0), EditorWithComboUIElement)
is the same as:
editorElem = (EditorWithComboUIElement)buttonElem.ChildElements(0);