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
1365
Column header size depends on content in cells?
posted

Dear infragistics,

I have an ultraGrid (Infragistics Winform UltraGrid 12.1 with latest update) and I've manually made a data schema in the grid's designer.

I've proceeded to make a Row Layout for Band 0 like: Standard View = true, Keep Headers With Cells = true, Label Position = Left. And I've only inserted 1 column (eventually) to get the grid to do what I want. Because...

It seems it's sizing the header of the column to the content of the cell. Which is wanted in most circumstances. But in my case I have the Label Position to the Left, so I want the header to size to it's own caption.

InitializeLayout looks like:

            Infragistics.Win.UltraWinGrid.UltraGrid grid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender;

            grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
            grid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
            grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single;
            grid.DisplayLayout.PerformAutoResizeColumns(true, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);

            Infragistics.Win.UltraWinGrid.UltraGridLayout layout = e.Layout;
            Infragistics.Win.UltraWinGrid.UltraGridOverride ov = layout.Override;

            ov.AllowColSizing = Infragistics.Win.UltraWinGrid.AllowColSizing.Free;

            foreach (var band in layout.Bands) {
                foreach (var col in band.Columns) {
                    col.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
                }

            }

I've included the file "longheader.png" to show what the problem is. Then when you doubleclick on the seperator on the right side of the header it actually snaps back to the size that i want, which you can see at "shortheader.png".

See, i've set AllowColSizing to Free. Doesn't work. I've set Runtime Label Sizing in the Rowlayout to None. Doesn't work. Can it be done? and how?

Thank you in advance for answering.

longshortheader.zip
  • 469350
    Offline posted

    Hi Danny,

    I took a look at this, and there does not appear to be any easy way to do this in code. The code that is called internally when you double-click on the right edge of the cell is not accessible via any public methods, and it's tightly tied to a particular UIElement.

    I think this is something of an oversight, and quite frankly, I'm surprised no one ever noticed it before. So I'm going to ask Infragistics Developer Support to create a case for you and write this up as a bug for developer review. So maybe we can add some new methods to do this in the future. Unfortunately, 12.1 is retired, so any new methods we added would only be available in the latest support versions, which means 13.1 and up (assuming we fix it soon).

    In the mean time, the only solution I can think of would be to explicitly set the width of the header in code.


                foreach (var band in layout.Bands)
                {
                    foreach (var col in band.Columns)
                    {
                        col.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
                        col.RowLayoutColumnInfo.PreferredLabelSize = new Size(100, col.RowLayoutColumnInfo.PreferredLabelSize.Height);
                    }
                }