This is a migrated thread and some comments may be shown as answers.

[Solved] Resizing images in GridImageColumn without distorting aspect ratio

2 Answers 631 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 09 Apr 2013, 06:38 PM
Hello.

I'm using a GridImageColumn in a document management scenario to display a small thumbnail of the document being referred to by each row in my grid.  I create the image column in code-behind, because my grid column set is somewhat dynamic based on configuration of our product.  In the method that creates the GridImageColumn, I have the following code:

gridView.Columns.Add(imageColumn);
imageColumn.HeaderText = label;
imageColumn.ImageHeight = 30;
imageColumn.ImageWidth = 30;

When I use this, my images are sized to the exact size specified, where I had instead hoped that it would create a bounding box around the image and preserve the aspect ratio of the image.

Is there any straightforward way to preserve the aspect ratio?

2 Answers, 1 is accepted

Sort by
0
Accepted
GreenLizzard
Top achievements
Rank 1
answered on 12 Apr 2013, 01:29 PM
Hi David,

Yes, by setting the height and width of the image it will appear with same size. As expected.

However, you can set the only one of the dimension (for example the width) and this will aspect the ratio of the other one (height).

Hope this helps.


0
David
Top achievements
Rank 1
answered on 12 Apr 2013, 01:44 PM
Thank you, that resolved it for me.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
GreenLizzard
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or