I have a button in my WinForms app and I added an image and text to it. I aligned the text to right and wanted to align the Background image to left but found out that it is not possible.
Is there any way to do that?
I have also tried to set just Image on the button but that couldn't be resized in the Button Properties.
May someone help me solve this out? Thanks so much.
In case that it is not possible I would have to resize every image in mspaint.
This is the result (as Background):
I need the BackgroundImage align to left.
This is result as Image when using align (not possible to resize)
Image
property to set your image (make sure it fits button height, you can change image size if you will open it from project resources folder)ImageAlign
to MiddleLeft
TextAlign
to MiddleRight
Do not change anything else. I.e. TextImageRelation
should be Overlay
. Result:
Set these properties of Button.
ImageAlign to MiddleRight
TextImageRelation to ImageBeforeText
TextAlign as MiddleCenter
To have it resized on Button. See below:
Bitmap image = Bitmap.FromFile(oFile) as Bitmap;
Bitmap resized = new Bitmap(image, new Size(30, 30));
button1.Image = resized;
button1.Text = "Button";
button1.ImageAlign = ContentAlignment.MiddleLeft;
button1.TextImageRelation = TextImageRelation.ImageBeforeText;
button1.TextAlign = ContentAlignment.MiddleRight;
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