Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
400
Repositioning UIElements in the grid
posted

 I'm creating a grid where each GroupByRow is indented to align with the header for the GroupByRow.Column. I did this by changing the GroupByRowUIElement.Rect my implementation of IUIElementCreationFilter.BeforeCreateChildElements :

public bool BeforeCreateChildElements(UIElement parent)
{
    if (parent is CellUIElement)
    {
        // Remove cells that fall under groupped columns
        UltraGridCell cell = parent.GetContext(typeof(UltraGridCell)) as UltraGridCell;
        if (!showCellValue(cell))
        {
            RowUIElement rowUIElement = parent.GetAncestor(typeof(RowUIElement)) as RowUIElement;
            Rectangle rowRect = rowUIElement.Rect;
            if (rowRect.Left < parent.Rect.Right)
                rowUIElement.Rect = new Rectangle(parent.Rect.Right, rowRect.Top, rowRect.Width - parent.Rect.Right + rowRect.Left, rowRect.Height);
            parent.Parent.ChildElements.Remove(parent);
            parent.Dispose();
            return true;
        }
    }
    else if (parent is GroupByRowUIElement)
    {
        UltraGridGroupByRow groupByRow = parent.GetContext(typeof(UltraGridGroupByRow)) as UltraGridGroupByRow;
        HeaderUIElement headerUIElement = groupByRow.Column.Header.GetUIElement(false) as HeaderUIElement;
        int newLeft;
        if (headerUIElement != null)
            newLeft = headerUIElement.Rect.Left;
        else
            newLeft = 1;

        parent.Rect = new Rectangle(newLeft, parent.Rect.Top, parent.Rect.Width - (parent.Rect.Left - newLeft), parent.Rect.Height);
    }
    else if (parent is GroupByRowDescriptionUIElement)
    {
        UltraGridGroupByRow groupByRow = parent.GetContext(typeof(UltraGridGroupByRow)) as UltraGridGroupByRow;
        HeaderUIElement headerUIElement = groupByRow.Column.Header.GetUIElement(false) as HeaderUIElement;
        int newLeft;
        if (headerUIElement != null)
            newLeft = headerUIElement.Rect.Left;
        else
            newLeft = 1;

        // Realign the description
        Rectangle descriptionRect = parent.Rect;
        Rectangle rowRect = parent.Parent.RectInsideBorders;
        parent.Rect = new Rectangle(newLeft, descriptionRect.Top, rowRect.Width, descriptionRect.Height);
    }
    return false;
}

Summaries are displayed in the GroupByRow positioned by their SourceColumn.

I use the InitializeGroupByRow event to set the GroupByRow.Description to the value of the GroupByRow's group column.

But grid still seems to think that the GroupByRow started all the way on the left instead of its indented position. So when the GroupByRow.Description is very short and there is a summary on the GroupByRow.Column, it figures that there's enough space between the left of the grid and GroupByRow.Column's summary to print the description and doesn't increase the height for the GroupByRow to draw the summary and the description on separate lines. Instead, I get overlapping text.

Is there a way to get the grid to realize that I've repositioned the GroupByRowUIElement and GroupByRowDescriptionUIElement so it could correctly determine whether there would overlap between text elements? The Course 51842 "Advanced Development with NetAdvantage" manual mentions a PositionChildElements() method that's called between BeforeCreateChildElements and AfterCreateChildElements. But that doesn't seem to be exposed. I've also tried resizing/repositioning the GroupByRowDescriptionUIElement and SummaryFooterUIElement as part of the GroupByRowUIElement's block in BeforeCreateChildElements. But that resizing seems to be overridden at some point by the default sizing behavior.

I hope I've adequately described my problem. Please let me know if I need to clarify any parts of it.

Thanks.

Parents
No Data
Reply
  • 400
    posted

    Here're a couple of screenshots to help clarify the problem:

    Without a summary in the GroupByRow's column:



    With a summary. Notice that the summary and the group by row description are overlapped in the 3rd GroupByRow.



     

Children