基于多次单击一个按钮创建顺序事件 [英] Creating sequential events based off clicking one button multiple times

查看:71
本文介绍了基于多次单击一个按钮创建顺序事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在尝试创建一个倒计时器,你想要倒数的时间是通过按钮输入而不是输入所需的价值。我想要做的是这样做,以便一旦输入小时时间,就可以点击确认按钮(或者在这种情况下为OK按钮)以输入所需分钟的数据。然后OK按钮应该能够在最终点击开始倒计时之前进入所需秒的输入。



整个安排看起来有点像一个计算器和我到目前为止的数字按钮可以输入小时文本框但不能移动到输入分钟或秒。



目前我的问题是我无法弄清楚如何做到这一点,甚至无法确认是否可能。我已经尝试查找C#顺序事件以及如何从一个处理程序创建多个事件但我没有提出太多有意义的事情。



如果有人对我在哪里可以找到这类信息有任何想法,或者知道如何做到这一点,我将非常感谢您提出的任何建议。



非常感谢



我尝试过:



private void btn1_Click(object sender,EventArgs e)

{

if(txt_Hours.Text ==)

txt_Hours.Text =0;



按钮b =(按钮)发件人;

txt_Hours.Text = txt_Hours.Text + b.Text;

解决方案

为什么要为自己复杂化?请参阅如何:使用DateTimePicker控件显示时间 [ ^ ]。

Hi there,

I'm currently trying to create a countdown timer where the time you want to count down from is input via buttons as oppose to typing in the required value. What I want to do is to make it so that once the "hour" time is put in, a confirm button (or OK button in this case) can be clicked to move onto inputting the data for the wanted "minutes". The OK button should then be able to move onto inputting for the wanted "seconds" before a final click should then start the countdown.

The whole arrangement looks a bit like a calculator and what I have so far is that the number buttons can input for the "hours" textbox but can't move over to input for "minutes" or "seconds".

My problem at the moment is that I can't work out how to do this or even confirm if it's possible in the first place. I have tried looking up C# sequential events as well as how to create multiple events from one handler but I'm not coming up with much that makes sense.

If anyone has any ideas on where I could find this kind of information or knows how I might do this I would greatly appreciate any suggestions you may have.

Thank you very much

What I have tried:

private void btn1_Click(object sender, EventArgs e)
{
if (txt_Hours.Text == "")
txt_Hours.Text = "0";

Button b = (Button)sender;
txt_Hours.Text = txt_Hours.Text + b.Text;

解决方案

Why complicate things for yourself? See How to: Display Time with the DateTimePicker Control[^].


这篇关于基于多次单击一个按钮创建顺序事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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