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?
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.
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; } } }
Heloo...
can i use this code when form load ?
Mike Saltzman said:
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.