您的位置:程序门 -> .net技术 -> c#



按钮的单击问题.....


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


按钮的单击问题.....[已结贴,结贴人:cyxif]
发表于:2007-03-16 11:47:03 楼主
想根据按钮是否按下来来做个判断
就是按钮按下时,定义一个bool值=1,没按=0
该怎么实现?
发表于:2007-03-16 11:51:161楼 得分:0
定义一个静态变量
public   static   int   isbtn   ;

然后在单击事件里写

isbtn   =   0;
发表于:2007-03-16 11:56:172楼 得分:0
bool
只能为true,flase!
发表于:2007-03-16 12:05:573楼 得分:0
根据flatstyle判断如何?
if(button1.flatstyle==flatstyle.popup)
{
}
if(button1.flatstyle==flatstyle.flat)
{

}
发表于:2007-03-16 16:23:314楼 得分:0
定义一个静态变量
public   static   int   isbtn   ;
然后在单击事件里写
isbtn   =   0;
具体怎么实现啊?
难道是在单击的时候赋给isbtn等于0?
发表于:2007-03-16 16:56:075楼 得分:10
private   bool   bpush   =   false;
private   void   button1_click(object   sender,   eventargs   e)
{
        bpush   =   !bpush;
        if(bpush)
                  button1.text   =   "1 ";
        else
                  button1.text   =   "0 ";
}
发表于:2007-03-16 17:06:576楼 得分:10
bool   类似enum,只有true,false   0和1纯属瞎扯,添加mouse事件可以改变bool的值

private   bool   ispressed   =   false;
                private   void   buttou_mouseup(object   sender,   mouseeventargs   e)
                {
                        ispressed   =   false;
                        this.text   =   ispressed.tostring();
                }

                private   void   button_mousedown(object   sender,   mouseeventargs   e)
                {
                        ispressed   =   true;
                        this.text   =   ispressed.tostring();
                }
发表于:2007-03-16 17:22:027楼 得分:0
bool  
true
false

大家太厉害了,怎么理解的都有
发表于:2007-03-16 18:02:518楼 得分:0
不好意思,我没说清楚.
意思就是true,false.嫌打着费劲,就直接打了个0,1上去.汗一个.
不过基本上目的达到了.
发表于:2007-03-16 18:08:529楼 得分:0
上面为正解,你在button的相应事件中设值相应的值就可以了


快速检索

最新资讯
热门点击