Hi
After Editing cell values i want to resize grid columns based on cell values. my code:
foreach (UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns)
{
col.PerformAutoResize();
}
When current cell value is bigger than pervious value its Grows properly but When current cell value is smaller than previous value it donot shrink, it keeps *Row Height as it is. ( Row Height - becoz Column's CellMultiline is True)
ya there are other cells in the column tht need more space...anyway, my problem is solved in other way so now no issue. Thanks
Hi,
PerformAutoResize on the column will, resize the column based on the contents of the cells in that column. It's based on the whole column, though, not just a single cell. So my guess is that the column is not shrinking because there is some other cell in the same column that needs more space.
I'm still not sure what any of this has to do with the row height. Nothing you have here will affect the height of the row in AfterCellUpdate.
My Code for grid rows and columns as below:
private void ultraGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e){ ultraGrid.DisplayLayout.Bands[0].Columns[1].CellMultiLine = Infragistics.Win.DefaultableBoolean.True; ultraGrid.DisplayLayout.Override.RowSizing = RowSizing.AutoFree; ultraGrid.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; foreach (UltraGridColumn ugColumn in ultraGrid.DisplayLayout.Bands[0].Columns) { ugColumn.PerformAutoResize(); } ultraGrid.DisplayLayout.GroupByBox.Hidden = true;}
private void ultraGrid_AfterCellUpdate(object sender, CellEventArgs e){
foreach (UltraGridColumn ugColumn in ultraGrid.DisplayLayout.Bands[0].Columns) { ugColumn.PerformAutoResize(); }}
After cell update, Current cell value is larger than previous value then column size grows properly but when Current cell value smaller than previous value then column size does not shrink properly. PerformAutoResize() shrink column size to max. cell value, correct ? but its shrinks to less than max. cell value.
I'm having a hard time understanding your question. How does autosizing the column relate to the height of the row? This code will never change the row height either bigger or smaller. If you want to auto-resize the rows, then you should use the PerformAutoSize method on the row.
BTW, the code you have here will only autosize the columns based on the visible cells in the grid. That is - the cells that are scrolled into view. You might want to consider using one of the other overloads of PerformAutoResize to include all of the rows.