I have an UltraWinGrid bound to a DataTable. There is an unbound column as well. When I click a button in my app, I add a row to this DataTable, and set the following 2 properties for the unbound column: gridRow.Cells["DELETE"].Appearance.Image = Properties.Resources.About16; gridRow.Cells["DELETE"].Appearance.ImageHAlign = HAlign.Center;
Then I call this: grid.DisplayLayout.Bands[0].Columns["DELETE"].PerformAutoResize(PerformAutoSizeType.VisibleRows);
I am attaching a screenshots for BEFORE and AFTER. I would like the column to resize to fit the size of the image, no more, no less. However, as you can see from the BEFORE that doesn't happen right away. If I click the button again to add another row, then it resizes properly (see AFTER). Is this a timing issue? If so, what event should I put the resize call in?
Thanks in advance!
The problem is that you are passing in PerformAutoSizeType.VisibleRows. The row is not visible, yet, because the grid has not painted.
Try passing in AllRowsInBand.
Or, try calling Refresh on the grid to force a paint before you call PerformAutoResize.
Hi Mike,
I'm trying to do similar thing, showing bitmap image (JPEG) in the the grid cell. But there's nothing in that cell where the image should be.
I'm using UltraWinGrid v10.3.
here is my code which resides in BeforeRowExpanded event:
ugSocialMediaContent.DisplayLayout.Bands(1).Columns("Image").Style = UltraWinGrid.ColumnStyle.Image Dim bitmapAvatar As Bitmap = New Bitmap(awebclient.OpenRead(ugSocialMediaContent.ActiveRow.Cells("ImageURL").Text)) ugSocialMediaContent.ActiveRow.Cells("Image").Appearance.Image = bitmapAvatar ugSocialMediaContent.Refresh() ugSocialMediaContent.DisplayLayout.Bands(1).Columns("Image").PerformAutoResize(PerformAutoSizeType.AllRowsInBand)
Please let me know what I'm doing wrong.
Thanks.
Hi,
You are mixing up two different functionaries here. If the Style of the column is set to Image, then this means the cell will display it's value as an image. So the DataType of the column has to be an image type like Image or Bitmap, and the cell will display it's Value as an image. The Appearance.Image will have no effect, because it doesn't make any sense to show an additional image in a cell whose value is an image already.
So if you set the column Style to image, you need apply your image to the cell's Value. If you want to use the Appearance, then don't set the Style - or at least use a Style other than Image.
Thanks, I've the loading the image part working, but now can't seem to get the image column to resize to the image's full size (48 x 48). Here's a screen shot:
Here's the piece of code right after the image load:
ugSocialMediaContent.Refresh() ugSocialMediaContent.DisplayLayout.Bands(1).Columns("Image").
PerformAutoResize(PerformAutoSizeType.AllRowsInBand)
I've the grid layout set to AutoFitStyle.ExtendLastColumn in InitializeLayout
event but turninng it off didn't help either.
It should look more like an avatar image like on this site.
Not sure what I'm missing here.
I don't think there is any way to do this via autosizing. The Image is sized to the cell in the grid, not the other way around.
You could, of course, set the MinRowHeight to the height of your image (plus a coupe of pixels for the borders) and that should fix it.
Thanks Mike.
Setting the height of the child row to the image height worked. Didn't find a property called MinRowHeight for the child row.
MinRowHeight is on the Override:
grid.DisplayLayout.Override.MinRowHeight
So it applied to all rows in the grid or all the rows of a particular band (if you use the band's Override instead of the DisplayLayout.Override).