How to resize an image on a button in C #?

Im working with window shapes. I have a button with an image inside. When Im trying to resize the button, the image inside does not change (remains unchanged). How to make a button image the size of a button?

Here is my code:

Image img = Image.FromStream(p); devBtn = new Button(); devBtn.Image = img; devBtn.Size = new Size((img.Width + 5), (img.Height + 5)); devBtn.Top = positionTOP; 

I am trying to resize a button as follows

 this.devBtn.Height= pictureBox1.Top + eY; this.devBtn.Width = pictureBox1.Left + eX; 
+6
source share
1 answer

Use the background image of the button as below, it will solve your problem:

 Image img = Image.FromStream(p); devBtn = new Button(); devBtn.BackgroundImage = img; devBtn.BackgroundImageLayout = ImageLayout.Stretch; devBtn.Size = new Size((img.Width + 5), (img.Height + 5)); devBtn.Top = positionTOP; 
+11
source

All Articles