Im working with windows forms.I have a button with a image inside. When Im trying to resize the button, the image inside doesn't resizing (stays the same). How can I make image of the button to be sized with 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;
Im trying to resize the button like this
this.devBtn.Height= pictureBox1.Top + e.Y;
this.devBtn.Width = pictureBox1.Left + e.X;
Use Background Image of button as mentioned 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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With