按钮图片 [英] Button image

查看:85
本文介绍了按钮图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮.我需要通过检查当前图像来设置两个图像.如果按钮图像为Image1,则应将其设置为Image2.如果图像是Image2,则应该 设置Image1.

I have a button in form. And I need to set two images by checking current image. If the button image is Image1 it should set Image2. If the image is Image2 it should set the Image1.

我当前的编码如下

button1.Image =属性.

button1.Image = Properties.Resources.Image1;

some1可以告诉我如何进行比较和设置图像.

推荐答案

使用button标签属性在图像上存储ID信息.

Use the buttons tag property to store ID info on the image.. Check that..

 

if(button1.Tag.ToString()=="Image1")

if (button1.Tag.ToString() == "Image1")

{

    button1.Image = Properties.Resources.Image1;

     button1.Image = Properties.Resources.Image1;

    button1.Tag ="Image1";

     button1.Tag = "Image1";

}

其他

{

    button1.Image = Properties.Resources.Image2;

     button1.Image = Properties.Resources.Image2;

    button1.Tag ="Image2";

     button1.Tag = "Image2";

}


这篇关于按钮图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆