[英]Using a timer to display text for 3 seconds?
是否可以使用計時器在標簽中顯示文本3秒鍾? FE當您保存某些內容並成功后,您會收到一條短信“成功!”。 3秒鍾,然后返回原始頁面。
有人知道如何使用標簽或消息框來執行此操作嗎?
是的,有可能...
您可以在將標簽文本設置為“成功”並將其設置為3秒鍾后打勾的地方啟動計時器,然后在timer_ticks事件中,您可以重定向到所需的頁面。
編輯 :啟動計時器的代碼-這是一個具有一個按鈕和一個標簽的簡單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();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.