Hello,
I'm running into an issue with AllowColumnSizing. I have a grid with a series of nested bands, and while normally I would like the columns to align across the bands, I do not want this to happen for this particular grid. One of the bands starts off displaying an image (gridcolumn.CellAppearance.Image = image;), and then after that image a set of columns. When I tried setting the value of AllowColumnSizing to be Free or None, the first column on my band gets squashed and hidden behind the image. How can I keep this from happening without hardcoding a width value for the first column in the band? Right now I have hardcoded the width value so I can see the "hidden" field, but that is not the optimal solution.
I have attached some screenshots which show the issue.
Thank you!
Steve
Hi Steve,
I'm afraid I am at a loss to explain this, then. Can you post a small sample project demonstrating this behavior?
Hi Mike,
We are setting AllowColumnSizing prior to auto resizing the columns. And we are also passing in AllRowsInBand ... Here is the call to resize method:
column.PerformAutoResize(
PerformAutoSizeType.AllRowsInBand);
Not sure what else we can try??
Thanks for all your help!
Steve Nugent said:We are adding the image with CellAppearance.Image to the column during InitializeLayout not during InitializeRow. Could this be the problem?
No, that's fine as long as you want the same image in every cell of the column. :)
Steve Nugent said:We are also doing the PerformAutoResize at the column level.
Are you doing this before or after you set the AllowColSizing? Make sure you do it after. And also make sure that you are passing in AllRowsInBand.
Steve Nugent said:It looks like we don't have the PerformAutoResize at the band or grid level because I don't see it as option. Maybe it was added in a release later than ours (we are on 7.3)?
Yes, that's correct, it was added later. So that just means you have to loop through the columns.
Steve Nugent said:Since we are doing the auto resize at the column level, it appears that the resizing doesn't take into account if there is data in the field along with the image because only the image is left displaying ...
It absolutely DOES take this into account. But only if the data has been loaded into the rows. If you call PerformAutoResize on the column in InitializeLayout, no rows will exist in the grid, yet. So you must make sure you specify AllRowsInBand so that the rows are forced to load before the resizing occurs.
We are adding the image with CellAppearance.Image to the column during InitializeLayout not during InitializeRow. Could this be the problem? ... We are also doing the PerformAutoResize at the column level. It looks like we don't have the PerformAutoResize at the band or grid level because I don't see it as option. Maybe it was added in a release later than ours (we are on 7.3)? Since we are doing the auto resize at the column level, it appears that the resizing doesn't take into account if there is data in the field along with the image because only the image is left displaying ...
Steve Nugent said:The band in question has an image displaying in the first column along with some data. When we set AllowColumnSiziing to be Free or None, the column size gets reduced so much that the data is not being seen any longer, just the image. Is there a way to keep the column from getting reduced so that the image and the data can still be seen together? Right now we are manually setting the width of the column so that both the image and the data can be seen when AllowColumnSizing is Free or None.
I think I understand what you are describing, but I really don't understand why it's happening. Perhaps it has to do with how or when you are applying the image to the cell. Typically, if you have an image in a cell, the image is determined based on some data in the cell or in the same row, and you would typically do this in the InitializeRow event of the grid.
Anyway... the grid does not automatically size a column to fit the data in that column. It really can't, because there's no way the grid can determine the synch point. The grid doesn't know when to size the columns. But you can do this very easily using the PerformAutoResize method on the column.There's also a method on the band and the on the layout, to size all of the columns at once.
So it seems like all you need to do here is something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.PerformAutoResizeColumns(false, PerformAutoSizeType.AllRowsInBand); }