[英]Setting background image of button in C#
I want to set an image as background of a button of Windows Forms. 我想将图像设置为Windows窗体按钮的背景。
The image is added to the project´s resources. 该图像将添加到项目的资源中。
How do I do this? 我该怎么做呢?
Simply set the BackgroundImage property of the Button. 只需设置Button的BackgroundImage属性即可。 An example:
一个例子:
button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Image));
在加载应用程序或进行设置时都可以使用它。
button.BackgroundImage = YourApplicationNamespace.Properties.Resources.yourImageHere;
In Visual Studio, you can do this: 在Visual Studio中,您可以执行以下操作:
BackgroundImage
item. BackgroundImage
项。 Or, from code you can do this: 或者,您可以通过代码执行以下操作:
button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Image));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.