开发者

How do I generate an Image through C# code?

I've got a button in my WinForms plugin. It's got an image on it. The thing is, when I click the button, I want the image to change from whatever image it is now, to whatever image I want it to be.

So basically how do i make button change its image? 开发者_如何学GoThe image type is System.Drawing.Image.


In order to change a Button's image in WinForms you set it's Image property. You can either load a bitmap from a file with Bitmap.FromFile, or you can draw an image using the Graphic class by creating a new instance of Bitmap using the Width/Height constructor (i.e. new Bitmap(100, 100)) and then use the Graphic.FromImage method. Lookup the documentation on the Graphic class for more info.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜