With an UltraCombo, I noticed that when the control is smaller than the dropped-down section, the dropped-down section and the control are left-aligned and the dropped-down section expands to the right. However, when the control is larger than the dropped-down section, the latter is right aligned. How can I align both sections on their left edge in all cases? The picture below displays the issue and expected result.
Thanks, Marcel
Mike,
Thanks for the update
Regards
Stephen
There have been no changes to this functionality that I know of - unless some part of this was a bug that was fixed, and I don't think that is the case.
I am facing the same issue - Has there been any updates to the functionality to do this any differently since 2009? Thank you
Here are my findings:
/// <summary>
/// This creation filter makes sure the left edges of the text and drop down sections
/// of the UltraCombo are aligned.
/// Without this, when the drop-down is narrower than the text portion
/// both sections have their right-edge aligned instead.
/// </summary>
private class GlueDropDownToLeftCreationFilter : IUIElementCreationFilter
{
#region Implementation of IUIElementCreationFilter
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
return false; // let the child elements be created normally
}
void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
if (parent is UltraGridUIElement)
UltraGridUIElement gridUIElement = (UltraGridUIElement)parent;
Control textSection = gridUIElement.Grid;
Control dropDownSection = gridUIElement.Control.Parent;
// this method is called more than once, the first time the drop-down section
// is not attached to the UIElements which explains this "if".
if (dropDownSection != null)
// get wanted location (just below text portion) in the
// textSection's parent's referential and convert to screen referential
Point location = new Point(textSection.Left, textSection.Bottom);
location = textSection.Parent.PointToScreen(location);
// when control has parent we need to convert the location back to this parent's referential
if (dropDownSection.Parent != null)
location = dropDownSection.Parent.PointToClient(location);
//we're good now
dropDownSection.Location = location;
#endregion
You may also want to take a look at the DropDownWidth property on the control. There are certainy special values, like -1, that can be used to size the dropdown to the control.