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
PerformAutoSize not working as expected
posted

I have a Hierarchical Datagrid from version 12.1.

I load a collection of class Employee in de Datasource. Each Employee has a property Tasks which is a collection of class Task.The property Tasks however is always initially empty (so the grid is 1 level deep).

In my app the enduser can assign a Task to an Employee. The Task row needs to be shown beneath the Employee row, this all works fine. But I also need to autosize all the columns of all the rows. And I want to size everything so that all the data in the cells are visible to the enduser.

I try to do this in the InitializeLayout eventhandler, as follows:

        private void ultraGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) {

            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;

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

            ov.AllowColSizing = Infragistics.Win.UltraWinGrid.AllowColSizing.Free;
            layout.Bands[0].Override.RowSpacingAfter = 2;
            layout.Bands[0].Override.RowSpacingBefore = 3;

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

        }

The PerformAutoResize in the foreach loop is not giving me the result I expected. The added Tasks at level 2 in the grid are not resized at all so it seems. Can you please help me Infragistics? I need your expert advice on this one.