如何通过使用计时器在c#windows应用程序中逐个显示多个问题 [英] How to show multiple questions display in one by one in c# windows application by using timer
本文介绍了如何通过使用计时器在c#windows应用程序中逐个显示多个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的先生,
如何通过使用计时器在c#windows应用程序中逐个显示多个问题。
Dear Sir,
How to show multiple questions display in one by one in c# windows application by using timer.
推荐答案
您好,
尝试这个而不是消息你可以显示你的问题:
Hi,
try this instead of message u can show ur question :
using System.Threading;
// Somewhere in your Form, for example in Form_Load event:
new Thread(new ThreadStart(delegate {
var d = new setLabelTextDelegate(setLabelText);
label1.Invoke(d, new object[] { "string 1" });
Thread.Sleep(3000); // sleep 3 seconds
label1.Invoke(d, new object[] { "string 2" });
Thread.Sleep(5000); // sleep 5 seconds
label1.Invoke(d, new object[] { "string 3" });
})).Start();
private delegate void setLabelTextDelegate(string text);
private void setLabelText(string text)
{
this.label1.Text = text;
}
这是简单的逻辑。
从哪里得到如果它来自DB然后返回行号也是1,2,3之类的那样。
声明全局变量作为needTODisplay = 1;
在计时器中检查needToDisplay with the Row Number并显示第一个问题并增加needtoDisplay。继续增加直到最后一个Question.If LastQuestion Found set needTODisplay = 1;
Hi,
Here is simple Logic.
From where you get the Questions.if its from DB then return Row Number also ex 1,2,3 like that.
Declare a Global Variable as needTODisplay=1;
In timer check the needToDisplay with the Row Number and display the 1st Question and increment needtoDisplay .Continue increment till the last Question.If LastQuestion Found set the needTODisplay=1;
更喜欢将计时器间隔设置为理想时间您想要显示每个问题。
然后在Timer_Tick中您必须添加用于连接Q源列表的代码。
问候
-Amir Mohammad Nasrollahi
Prefer you setting the timer interval to ideal time which you want each question be shown.
then in Timer_Tick you must add codes for connecting to list of your Q source.
Regards
-Amir Mohammad Nasrollahi
这篇关于如何通过使用计时器在c#windows应用程序中逐个显示多个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文