如何以编程方式更改窗体上的背景图像#
当我单击按钮时,我需要更改表单的背景图像,并在第二次单击按钮时再次将其更改回 null,我该如何执行此操作?
I need to change the background image of my form when i klick a button, and change it back to null again the second time it is clicked, how can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用BackgroundImage属性:
隐藏图像:
将此源代码放入ClickButton方法中:
Use BackgroundImage property:
to hide the image:
Put this source code to ClickButton method:
您应该能够从该按钮的事件处理程序设置表单的BackgroundImage 属性。
例如你可以这样做:
要删除图像,请将属性设置回 null。
图像也可以来自资源。
You should be able to set the BackgroundImage property of your form from the event handler of that button.
For example you could do it like this:
In order to remove the image, set the property back to null.
The image can also come from a resource.