Using the Infragistics grid bound to a data table. The data table has two columns:
1) Competitor Item: string
2) Image 1: System.Drawing.Image
Not every row has a value for the Image 1 column, but those that do have a value that is a System.Drawing.Image. Sizes of the images are all over the map (310x182, 960x720, etc)
The column is set to Style= Image The column cell appearance is set to Center and MIddle.
When I bind the data, I can see my an image in the cell for rows that have an image. However, the image itself is very tiny and always stuck in the upper left corner, regardless of how i size the column or row.
Any thoughts?
Hello Chris,
Thank you for the provided feedback.
If you have any other questions please feel free to let us know.
Call off the dogs. A creation filter was added that seems to be intercepting the drawing of images in cells. I need to dig further, but I think this probably the issue. Sorry about the wild goose chase.
For grins I went and and implemented the code you suggested. I can confirm the row sizing is on auto free because I can manually drag the row size larger / smaller/
I also added the code in the _InitializeRow event, with a breakpoint on
e.Row.Height = Math.Max(image.Height, e.Row.Height)
I can verify the image heights are indeed in the range of 300 all the way up to 700 high. And the row is being sized appropriately.
Yet the image itself remains tiny and in the upper left corner just like my attached screenshot.
Thanks for the reply Mike.
I don't know if you can make it out from my attached screenshot, but the rows heights for the rows I've shown are MUCH larger than the images themselves. In fact the part I show has two rows taking up the entirety of the visible grid. And yet the image itself it still tiny and in the upper left corner.
Hi,
The grid doesn't make any attempt to size the rows based on the image. If you want to do that, you will need to set the height of the row yourself.
I assume, since some of your rows have images and others don't, that you want the row height to be variable. You wouldn't want to waste space making all of the rows the same height when some don't have an image.
So if that assumption is correct, you could do something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridOverride ov = layout.Override; // Let each row in the grid be a different height. ov.RowSizing = RowSizing.AutoFree; } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { Image image = e.Row.Cells["Image 1"].Value as Image; if (image != null) { e.Row.Height = Math.Max(image.Height, e.Row.Height); } }
The grid will maintain the aspect ration of the image by default, so this code will work okay as long as your images are not wider than the column. You might want to set the Width on the column to the width of the widest image first.