Button image and text positioning

I have a button in my form. I want to have an image on the left and text on the right, for example:

Image Text

But the problem is that the image is not stretched here. I mean, it does not fit the button.

So I tried to set the BackGroundImage property instead of the Image property.

Now I get the image stretched. But I can not get the correct format. I mean, now I can’t get the image on the left and the text on the right.

Is there any other control that I can use instead of a button to overcome this problem?

+4
source share
5 answers

I do not think that using stretch marks will be anyway. How is the border supposed to be stretched? With the middle word imagealign set and the middleright text set, I was able to make this button, it's 82X48. The image I used is 52X39. I used paint to resize the image.

enter image description here

+2
source

The button has the TextImageRelation property, set it to ImageBeforeText . Set the Image property to your image, and you go.

+4
source

A simple way that may work well is to set the image and buttons inside the panel. This gives you the flexibility of placing text, scaling an image, and using an anchor or dock for the size of controls using the panel and form. Not tested, but sounds like it might work ...

+2
source

If you used Button control .. and want to add an image to it

Create a new button and do something in it properties

  • Image : you can insert an image from anywhere (local or resource).
  • ImageAlign : set it to the middle left
  • TextAlign : Set it to Middle Right

It was tested on VB.NET 2005

+1
source

To resize the image on a button, you can use the image property. Your image will be resized to a certain size.

 Button2.Image = Image.FromFile("c:\image.jpg").GetThumbnailImage(20, 20, Nothing, IntPtr.Zero) 
0
source

Source: https://habr.com/ru/post/1482674/


All Articles