to saucer(思归) ( 你的程序是吧所有的号码全部显示label上了,我要的是号码变化显示阿 to whxbb(whxbb) (交换顺序也不行阿,用TIMER控件?怎么用阿,给我个思路好吗,谢谢
试试using System; using System.Collections; using System.Windows.Forms;class LabelTestForm : Form { Label label1; Button button1; ArrayList aList; public LabelTestForm() { aList = new ArrayList(); for (int i=1; i <=5; i++) aList.Add(i.ToString()); label1 = new Label(); label1.Text = ""; label1.Size = new System.Drawing.Size(64, 16); label1.Location = new System.Drawing.Point(88, 40);
Controls.Add(label1); button1 = new Button(); button1.Text = "Click Me!"; button1.Location = new System.Drawing.Point(88, 100); button1.Size = new System.Drawing.Size(100, 40); button1.Click += new EventHandler(btnClick); Controls.Add(button1); } void btnClick(Object sender, EventArgs e) { //MessageBox.Show(aList.Count.ToString()); for (int i=0; i < aList.Count; i++) { MessageBox.Show(aList[i].ToString()); //label1.Text += aList[i].ToString(); label1.Text = aList[i].ToString(); } } static void Main() { Application.Run(new LabelTestForm()); } }
to saucer(思归) 我都使用过了什么arrlist,数组阿,记录集阿都不行,你用MessageBox.Show(aList[i].ToString()); 每一次点击可以看出效果,但是你吧这行取消,看看,是不是一闪而过阿,
嘿嘿, kphaitao(Headman) 说得对,你需要用Timer,譬如using System; using System.Threading; using System.Collections; using System.Windows.Forms;class LabelTestForm : Form { System.Windows.Forms.Timer Clock; Label label1; Button button1; ArrayList aList; int n=0; public LabelTestForm() {
aList = new ArrayList(); for (int i=1; i <= 5; i++) aList.Add(i.ToString()); label1 = new Label(); label1.Text = ""; label1.Size = new System.Drawing.Size(64, 16); label1.Location = new System.Drawing.Point(88, 40);
Thread.Sleep(100);改为://挂起当前线程3毫秒
Thread.Sleep(1000);试试?
label1.Text += rs[j];
不行啊,无论我挂起多久都不行啊,始终不能出现号码变换显示的效果,总是一闪而过啊to saucer(思归)
你的方法更不行了
Thread.Sleep(100);换一下顺序呢,要不你用timer控件
你的程序是吧所有的号码全部显示label上了,我要的是号码变化显示阿
to whxbb(whxbb) (交换顺序也不行阿,用TIMER控件?怎么用阿,给我个思路好吗,谢谢
using System.Collections;
using System.Windows.Forms;class LabelTestForm : Form
{
Label label1;
Button button1;
ArrayList aList; public LabelTestForm()
{
aList = new ArrayList();
for (int i=1; i <=5; i++)
aList.Add(i.ToString()); label1 = new Label(); label1.Text = "";
label1.Size = new System.Drawing.Size(64, 16);
label1.Location = new System.Drawing.Point(88, 40);
Controls.Add(label1); button1 = new Button();
button1.Text = "Click Me!";
button1.Location = new System.Drawing.Point(88, 100);
button1.Size = new System.Drawing.Size(100, 40); button1.Click += new EventHandler(btnClick); Controls.Add(button1);
} void btnClick(Object sender, EventArgs e)
{
//MessageBox.Show(aList.Count.ToString());
for (int i=0; i < aList.Count; i++)
{
MessageBox.Show(aList[i].ToString());
//label1.Text += aList[i].ToString();
label1.Text = aList[i].ToString();
}
} static void Main()
{
Application.Run(new LabelTestForm());
}
}
我都使用过了什么arrlist,数组阿,记录集阿都不行,你用MessageBox.Show(aList[i].ToString());
每一次点击可以看出效果,但是你吧这行取消,看看,是不是一闪而过阿,
Update();
Thread.Sleep(1000);
for( j=0;j<rs.Length;j++){
// arr.Add(rs[j]);
label1.Text = rsid[j]+rs[j];
Thread.Sleep(100);
label1.Update();
if (j==rs.Length-1) j=0;
//if (j==-1) break;
}
using System.Threading;
using System.Collections;
using System.Windows.Forms;class LabelTestForm : Form
{
System.Windows.Forms.Timer Clock;
Label label1;
Button button1;
ArrayList aList; int n=0; public LabelTestForm()
{
aList = new ArrayList();
for (int i=1; i <= 5; i++)
aList.Add(i.ToString()); label1 = new Label(); label1.Text = "";
label1.Size = new System.Drawing.Size(64, 16);
label1.Location = new System.Drawing.Point(88, 40);
Controls.Add(label1); button1 = new Button();
button1.Text = "Click Me!";
button1.Location = new System.Drawing.Point(88, 100);
button1.Size = new System.Drawing.Size(100, 40); button1.Click += new EventHandler(btnClick); Controls.Add(button1);
} void btnClick(Object sender, EventArgs e)
{
Clock=new System.Windows.Forms.Timer();
Clock.Interval=1000;
Clock.Start();
Clock.Tick+=new EventHandler(Timer_Tick);
} public void Timer_Tick(object sender,EventArgs eArgs)
{
if (n < aList.Count)
{
label1.Text = aList[n].ToString();
//Update();
n++;
button1.Enabled = false;
} if (n >= aList.Count)
{
n=0;
Clock.Stop();
button1.Enabled = true;
}
} static void Main()
{
Application.Run(new LabelTestForm());
}
}