none
Cannot change image size of images on buttons.

    Question

  • I added a few images to buttons but I cannot change the size of the image so they better fit the buttons. All the size related options in the properties tab of the solution explorer are gray and unmodifyable. 

    What is the solution?

    • Moved by CoolDadTx Thursday, August 24, 2017 2:06 PM Winforms related
    Thursday, August 24, 2017 8:24 AM

Answers

  • Humm, I'm not seeing white outline. See the pic attached for what I see there. The image is magnified by graphics software to allow me to make sure there's no "white outline".

    Make sure you're using PNG format file instead of GIF. GIF only uses one color as transparent instead of using Alpha channel and can cause white border when performing transparent Blt with most GDI+ rendering controls.

    • Edited by cheong00 Friday, August 25, 2017 6:54 AM
    • Marked as answer by bask185 Tuesday, August 29, 2017 6:05 AM
    Friday, August 25, 2017 6:46 AM

All replies

  • Don't put it under "Image" property, but "BackgroundImage" property instead. And then set BackgroundImageLayout to "Zoom" so it resize with proportion.
    Thursday, August 24, 2017 9:30 AM
  • I added a few images to buttons but I cannot change the size of the image so they better fit the buttons. All the size related options in the properties tab of the solution explorer are gray and unmodifyable. 

    What is the solution?

    You couldn't use it like that, you have to pub a com like label on it, but you could set it's size, like this:


    Thursday, August 24, 2017 10:15 AM
  • Hi bask185,

    Of cause you can not change the size of the image, the image is fixed in the button if you set the image property of the button, as a alternative solution, you can set the image as a background for the button just as cheong00 said.

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 25, 2017 1:51 AM
    Moderator
  • The zoom as well as the stretch option add white outlines to the image which isn't making it prettier. I think I will leave it like how it is now and If I really need bigger images I'd go for 電腦神手吳子陵's solution with the addition of a label.

    Thank you for your help,

    Friday, August 25, 2017 6:20 AM
  • Hi bask185,

    >>The zoom as well as the stretch option add white outlines to the image which isn't making it prettier.

    The white outlines is because the width and length of the picture is different from the button, try to set the BackgroundImageLayout to Stretch instead:

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 25, 2017 6:30 AM
    Moderator
  • Humm, I'm not seeing white outline. See the pic attached for what I see there. The image is magnified by graphics software to allow me to make sure there's no "white outline".

    Make sure you're using PNG format file instead of GIF. GIF only uses one color as transparent instead of using Alpha channel and can cause white border when performing transparent Blt with most GDI+ rendering controls.

    • Edited by cheong00 Friday, August 25, 2017 6:54 AM
    • Marked as answer by bask185 Tuesday, August 29, 2017 6:05 AM
    Friday, August 25, 2017 6:46 AM
  • That must be it, some of the icon are GIF. 
    Friday, August 25, 2017 10:08 AM
  • Hi bask185,

    So how about set the BackgroundImageLayout to Stretch?

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 28, 2017 6:47 AM
    Moderator
  • Thanks! That's worked or me
    Wednesday, April 17, 2019 10:34 AM
  • Both Stretch and Zoom should have the same effect because he was fitting the GIF image to a control with different size.

    The fact that the process of color quantization can change the colors of pixel to be slightly different than original - therefore don't exactly match the color to be set as transparent in GIF palette and makes the ought-to-be-transparent color opaque, hence the white line, was discussed in varies places in newsgroup age.




    • Edited by cheong00 Wednesday, April 17, 2019 2:00 PM
    Wednesday, April 17, 2019 1:57 PM