是否可以使用计时器在标签中显示文本 3 秒左右?
F.E. 当您保存某些内容并且成功时,您会收到一条短信“成功!” 3秒后返回原页面。
有人知道如何使用标签或消息框来做到这一点吗?
是的,有可能...
您可以在将标签文本设置为“成功”的位置启动计时器,并将其设置为 3 秒后滴答,然后在 timer_ticks 事件中,您可以重定向到您想要的页面。
Edit:启动计时器的代码 - 这是一个简单的 Windows 窗体,有一个按钮和一个标签
public partial class Form1 : Form
{
//Create the timer
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
public Form1()
{
InitializeComponent();
//Set the timer tick event
myTimer.Tick += new System.EventHandler(myTimer_Tick);
}
private void button1_Click(object sender, EventArgs e)
{
//Set the timer tick interval time in milliseconds
myTimer.Interval = 1000;
//Start timer
myTimer.Start();
}
//Timer tick event handler
private void myTimer_Tick(object sender, System.EventArgs e)
{
this.label1.Text = "Successful";
//Stop the timer - if required
myTimer.Stop();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)