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
75
UltraWinGrid: Stretch a column to fill available grid width
posted

In the Microsoft DataGridView, setting Layout.AutoSizeMode = Fill for any column autosizes the column to fill the remaining width of the grid.   AutoSizeMode in the UltraWinGrid doesn't look it does the same thing as DataGridView.

How do I do this in UltraWinGrid?

Parents
  • 469350
    Verified Answer
    Offline posted

    The AutoFitMode property on the DisplayLayout is similar. There's an option to make the last column fill the available space in the grid.


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridOverride ov = layout.Override;


                layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
            }

    If you don't want the fill column to be the last one, then you could use the ResizeAllColumns and lock the widths of the other columns.


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridBand band = layout.Bands[0];
                UltraGridOverride ov = layout.Override;

                layout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
                foreach (UltraGridColumn column in band.Columns)
                {
                    if (column.Key != "String 1")
                    {
                        column.MinWidth = column.MaxWidth = column.Width;
                    }
                }
            }

     

Reply Children