如何识别用户第一次或第二次单击按钮

编程入门 行业动态 更新时间:2024-10-12 03:27:59
本文介绍了如何识别用户第一次或第二次单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何识别用户第一次或第二次点击按钮 as当他即将点击按钮时,它有文字---选择 和它有的时间--- UN选择

How can i Identify that User has Clicked a Button First Time Or second Time as When he was about to click button FIRST TIME it has text --- Select and Secnd Time it has --- UN Select

推荐答案

我想你甚至不需要你可以使用的计数器一个布尔也可以做多种方式: I think you don''t even need a counter you can use a boolean as well and you can do it numerous ways: public class MyProg { private int counter = 0; //Button click event private void myButton_click(object sender, EventArgs e) { counter++; } }

= OR = 考虑你的按钮''文字是0.

=OR= consider your button''s text is 0.

protected void myButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; btn.Text = (Int32.Parse(btn.Text) + 1).ToString(); }

====================== ====编辑========================== 这是一个更简化的代码。您可以将该函数写入MyButtonHandler。

==========================EDIT========================== Here is a more simplified code for you. You can write that function to the MyButtonHandler.

Button b1 = CreateMyButton(); b1.Click += new EventHandler(this.MyButtonHandler); ... void MyButtonHandler(object sender, EventArgs e) { ... }

OI

Good luck, OI

你好, 听起来你需要一个切换功能: Hi, Sounds like you need a toggle functions: private bool _butonSelected = false; private void button1_Click(object sender, EventArgs e) { ToggleButtonText() } private void ToggleButtonText() { if (_butonSelected) { button.Text = "Select"; _butonSelected = false; } else { button.Text = "Un Select"; _butonSelected = true; } }

问候 Jegan

Regards Jegan

private void btnWhatever_Click(object sender, EventArgs e) { if(btnWhatever.Text == "Select") { btnWhatever.Text = "UN Select"; } else if (btnWhatever.Text == "UN Select") { btnWhatever.Text = "Select"; } // Your code goes here... }

更多推荐

如何识别用户第一次或第二次单击按钮

本文发布于:2023-11-23 04:27:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620089.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   按钮   如何识别   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!