I created RDLC report layouts by using Visual Studio Report Designer.
I need to display image on textbox. The image was set center align by Chris Hays 's method. But This method must set sizing to be "Clip"
So It has a problem because when Image which it was getting from database is bigger than textbox. It would clipped like below.
I tried to use sizing with "Fit Proportional" Mode. It can't set centered image by Chris Hays 's method.
But if I use sizing with "Fit to size". I can ignore centered image. But if some image is very small. It will lose quality.
What should I do if I need to
1.Centered image
2.Fit to textbox if image is bigger than textbox.
3.Original size if image is smaller that textbox.
I can resolved this problem by created two image control.
First image control -It was set sizing "Fit"
Second image control- It was set sizing "Clip" and used Chris Hays 's method for centered image.
Both two image controls was set Visibility property by expression
if a width of image is bigger than textbox , First image control will show and second will hide.
if a width of image is smaller than textbox , First image control will hide and second will show.
I can get a width of image by this code
96 is dpi
After I known a width of image from above expression. I will use it for set Visibility Property of First Image like these
2.6 is widht of my textbox.
And Set Visibility of Second Image by the other hand.
If you're using the same sizes of the tutorial you could try and set the
Sizing
property by using the following expression: