Hi
I have an Ultragrid with two bands. the colsizes are synchronised.The columns don't get resized when a text longer than the column's width is entered.
How can I achieve that?
I already tried:DisplayLayout.PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand, false);
which led to very "interesting" behaviour. Meaning, the grid gets resized, but I couldn't figure out how.Sometimes the column got resized based on cell content sometimes based on header content.
Any ideas how I can resizes my columns? (would be nice, if I could define that per column)
P.S.I'm using v2010.1
Thanks
has anybody an idea? :)
Hi,
You could try the following:
//allow columns in different bands to be resized independantly
ultraGrid1.DisplayLayout.Override.AllowColSizing = Infragistics.Win.UltraWinGrid.
.Free;
//perform resizing
ultraGrid1.DisplayLayout.PerformAutoResizeColumns(
);
Let me know if this is helpful for you.
Regards,
- Stefaniya
thanks for your answer.
Well, with your code the columns/content get resized as expected.But without synchronised bands, it's very confusing.
is there no way to size my content with synchronised bands?
I'm not sure I understand what the problem is. If your columns are synchronized (which is the default) and you call PerformAutoResizeColumns on the grid, then the width of the columns will be adjust so that every value in every cell of the grid will fit within the column without the need for the user to scroll. This includes the column header - so if the longest text in any cell is exceeded by the width of the column header, then the column header will determine the column width just as if the header were a cell.
Is that not the behavior you want? If not, then what exactly do you want the behavior to be?
There is also a method on each column called CalculateAutoResizeWidth which calculates the width that the column should be but does not actually size it. So you could use this method to calculate the width based on whatever options you like and then set the Width on the column explicitly.
Sorry for my late response.
Yes, this is exactly the result I'd like, but I doesn't behave like this.I have two bands and it seems that only the childband's columns/rows are used for resizing.
gridname.DisplayLayout.Bands[0].Columns[i].PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
Okay, now I'm afraid you've lost me.
mhaeberle said:it works perfectly when only Band 0 is synchronized and Band 1 (child) is not.
This doesn't make any sense. The Column widths in the two bands are either synchronized or they are not. If they are synchronized, they are synchronized with each other. So one cannot be synchronized without the other - what would it be synchronized to?
mhaeberle said:All columns have their autosizemode property set to default
This has no effect on anything you do in code, it only affects what happens when the user double-clicks the right edge of the column header.
Perhaps what's happening here is that the grid does not account for the synchronized column when it autosizes - it only accounts for the column itself. So the last column you autosize will affect both synchronized columns.
In that case, there are two possible solutions.
1) Turn off the synchronization.
2) Don't use PerformAutoResize, but instead use the CalculateAutoResizeWidth method. This method calculates and returns the size without applying to the column. So you could get the width of each column and then set both column widths to the greater of the two.
After some testing I found out, that it works perfectly when only Band 0 is synchronized and Band 1 (child) is not.If both are synchronized the behaviour explained above occurs.
All columns have their autosizemode property set to default and some of the columns in Band 1 have CellMultiline set to true