Hello,
I've got a couple Ultradropdownbuttons in a form. Wired up and working fine. The only issue is one of space. I need to get all the reduction in size I can out of this and to that end I would like to not show the dropdown arrow at all. The control is replacing a standard button and I'd like to have the Ultradropdownbutton take up the same screen real estate as the standard Ultrabutton with a 16x16 image and no text, no dropdown arrow. The buttons' style is set to DropDownButtonOnly.
Any ideas?
Thanks!
Hi,
Yeah, it looks like there is no separate element for the dropdown arrow, so you would have to use a DrawFilter instead of CreationFilter to stop the SplitButtonUIElement from drawing the arrow.
This is a bit tricky, too, because the drodpown arrow is drawn using operating system themes, so you would have to turn off Themes and also cancel the BeforeDrawForeground phase of the drawing.
Turning off themes can be done via the appearance:
this.ultraDropDownButton1.Appearance.ThemedElementAlpha = Alpha.Transparent;
And the DrawFilter would look something like this:
public class MyDrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { return true; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is SplitButtonUIElement) return DrawPhase.BeforeDrawForeground; return DrawPhase.None; } #endregion }
Thanks for the reply Mike. I ended up using an UltraButton and handling the events myself. For my instruction though, perhaps you'd take a look at the following:
I attempted to use a creation filter, but there doesn't appear to be a good way to do this with the UltraDropdownButton control. Or at least, if there is, I'm missing it.
I first tried:
Friend Class NoDropDownButtonCreationFilter
Implements Infragistics.Win.IUIElementCreationFilter
Public Sub AfterCreateChildElements(parent As Infragistics.Win.UIElement) Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements
Dim editorElement As Infragistics.Win.Misc.DropDownButtonControlUIElement = CType(parent, Infragistics.Win.Misc.DropDownButtonControlUIElement)
If editorElement IsNot Nothing Then
Dim dropdownButtonElement As Infragistics.Win.DropDownButtonUIElement = CType(editorElement.GetDescendant(GetType(DropDownButtonUIElement)), DropDownButtonUIElement)
Dim textElement As Infragistics.Win.EditorWithTextUIElement = CType(editorElement.GetDescendant(GetType(EditorWithTextUIElement)), EditorWithTextUIElement)
If dropdownButtonElement IsNot Nothing AndAlso editorElement.ChildElements.Contains(dropdownButtonElement) Then
editorElement.ChildElements.Remove(dropdownButtonElement)
If textElement IsNot Nothing Then
textElement.Rect = editorElement.RectInsideBorders
End If
End Sub
Public Function BeforeCreateChildElements(parent As Infragistics.Win.UIElement) As Boolean Implements Infragistics.Win.IUIElementCreationFilter.BeforeCreateChildElements
Return False
End Function
End Class
However, the parent only has one ChildElement which is Infragistics.Win.Misc.SplitButtonUIElement. There are no ChildElements on that class so I see no way to remove one of them from the collection. Do you have any suggestions about where to hide the dropdownbutton in this case?
There's no property to remove the dropdown arrow. But there are a couple of approaches you could take here.
One approach would be to remove the dropdown arrow using a CreationFilter. This is not too difficult, but there may be a bit of a learning curve if you haven't used CreationFilters before.
Another approach would be to use a different control. You could, for example, use a regular UltraButton or maybe an UltraCheckEditor in Button style. With this approach, you would have to handle events and show the dropdown in code, of course.