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?
Hi,
Using InitializeLayout is a good idea, since it fires after you set the grid's DataSource.
But yes, you COULD use the same code in the Form_Load. The only thing you would have to change is where you get the layout from:
UltraGridLayout layout = this.ultraGrid1.DisplayLayout;
You would, of course, have to do this AFTER you have set the grid's DataSource - otherwise the columns would not yet exist.
Heloo...
can i use this code when form load ?
Mike Saltzman said:
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; } } }
I discovered what I am missing: DisplayLayout.Bands[0].Columns["name"].RowLayoutColumnInfo.WeightX = 1.0F for all columns I want to be resized (with optional different weights!)
i have a checkbox column that I do not want to participate in resizing. In the designer I set Width, MinWidth and MaxWidth to 50. I have set AutoSizeMode to None and LockedWidth to true. (DisplayLoayout.AutoFitStyule is set to ResizeAllColumns) All to no avail . The column is still resized when I send DisplayLayout.PerformAutoResizeColumns(false, PerformAutoSizeType.VisibleRows) ALL columns are resized! What am I missing?
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; }
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.