0

I used the following code in a VB.Net forms application:

    Dim btnShowHideSize As New Size(30, 30)
    btnShowHide.Size = btnShowHideSize
    Dim img As New Bitmap(Resources.change2)
    Dim img2 As New Bitmap(img, btnShowHideSize)
    btnShowHide.BackgroundImage = img2
    btnShowHide.BackgroundImageLayout = ImageLayout.Stretch

The image will expand, but not shrink. When I step through, I see that img size is 80,80 and img2 size is 30,30. Howewver, the image is not shrinking - it is getting cut off. If I go above 80,80 e.g. 200,200, the image does expand.

Is shrinking an image not possible?

Chiwda
  • 1,233
  • 7
  • 30
  • 52
  • Why don't you try sizing the button instead of the image? – decyclone May 26 '12 at 05:45
  • I did. I tried various sizes as mentioned in my post. But ultimately I want the button to be 30x30. – Chiwda May 26 '12 at 08:34
  • What I am saying is don't assign any size to the image. Just the button and the image will resize itself to fit. – decyclone May 26 '12 at 14:29
  • Thanx @decyclone That is what I had initially. I just assigned it through the properties sidebar - it didn't work either as image or as background image. Then I blanked out the value in the properties sidebar and assigned it in the code. btnShowHide.BackgroundImage = Resources.change2 btnShowHide.BackgroundImageLayout = ImageLayout.Stretch That didn't work either, and that is when I tried all this fancy code above. I don't know how to do a new line in this but each line starting with btnShowHide is a new line. – Chiwda May 28 '12 at 05:30

0 Answers0