Resizing Infragistics UltraGrid Ideal for Its Content

How to resize an entire ultragrid control in code to display its contents? There is no space (the problem is that the data table inside is sometimes small, sometimes large)

I have:

-----------------------------
|   |   |    |    blank      |
|   |   |    |               |
|   |   |    |               |
| ------------      blank    |
|                            |
|   blank                    |
|____________________________|

and I want the borders to be snugly attached to the grid. I tried: a) read DefaultLayout.Bands (0) .GetExtent () ~ always gives the same number b) read the data source size / height and ~ always gives the same number

Do I need to handle some change layout events? Or is it some kind of grid properties file that needs to be processed?

+4
source share
2 answers

, . , RowLayouts, , , ..

GetExtent . , , . , , , , GetExtent .

, UIElements.

    private void AutoSizeGridToContents(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
    {
        UltraGridLayout layout = ultraGrid.DisplayLayout;
        UltraGridBand rootBand = layout.Bands[0];
        int extent = rootBand.GetExtent(BandOrigin.PreRowArea);

        UIElement gridElement = layout.UIElement;
        UIElementBorderStyle borderStyle = gridElement.BorderStyle;
        Border3DSide borderSides = gridElement.BorderSides;
        UIElementBorderWidths borderWidths = DrawUtility.CalculateBorderWidths(borderStyle, borderSides, gridElement);
        extent += borderWidths.Left + borderWidths.Right;

        UIElement scrollbarUIElement = gridElement.GetDescendant(typeof(RowScrollbarUIElement));
        if (null != scrollbarUIElement)
            extent += scrollbarUIElement.Rect.Width;

        ultraGrid.Width = extent;
    }

, .

+1

AutoFitStyle DisplayLayout. , :

ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;

.

-1

Source: https://habr.com/ru/post/1617695/


All Articles