1. If you are adding a background image
So here should use button.backgroudimage = ""; To set the picture
And should not use Button.image = "";
Because using Backgroudimage to set the background image, we can also use the
BackgroundImageLayout to adjust the picture so that the picture is better displayed on the button
Commonly used:
1 This Global:: Test.Properties.Resources.btn_reset_out; // set the path to the picture 2 this. btnreset.backgroundimagelayout = System.Windows.Forms.ImageLayout.Stretch; // Set the display mode of the picture, stretch to fill the button, if the picture is not large enough, the picture will be stretched
View Code
2. Then you will see that despite the addition of a background image, but also set up a stretch of the picture, but the effect is very bad
How can there be a border ah, this how ugly ah, since there is a border, then cancel the border bar
However, the border property of the button was not found, but the FlatStyle property was found (a property that determines the appearance of the control).
Regardless of, first try to what changes, finally flat feel more in line with our taste,
It's a very thick frame, but it still looks uncomfortable, and there's a little white box.
Just can't find the border property, the original is hidden in the flatappearance below, direct bordersize changed to 0
The effect immediately becomes as follows:
Oh, that annoying white box also disappeared, the overall look feel comfortable a lot of ah,
But careful you must also see, because the background picture of the button is rounded, the four corners on the incredibly still have
That ghost white border!!!! , the effect of running is more obvious, especially when the mouse moves in and out:
and
The left picture is the mouse to move in front, looks very comfortable, and the right picture is the mouse to move in, rub, four corner, this is too obvious, obsessive-compulsive I can not accept it!
From the beginning to now toss for so long, see to be done when, incredibly still have such a small problem. Microsoft's bug is not a problem???
Finally found or I was wrong, the solution is as follows:
Still in just that flatappearance attribute, but this time change is Mousedownbackcolor,mouseoverbackcolor are set to Transparent (transparent color)
And, of course, the final setup.
This.btnReset.BackColor = System.Drawing.Color.Transparent;
C # (WinForm) to add a background picture to a button