主题:一个在循环中显示数据的问题!!!
这是在C#的一个小例子, 我希望LABLE1显示1-10,能在屏幕上依次看到1,2-10;
但是事实上只能显示10,似乎显示是在循环结束后才运行的,请高手赐教;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 10; i++)
{
label1.Text = i.ToString();
//延时
for (int j = 1; j <= 100000000; j++) { }
}
}
}
}[em18][em18]
但是事实上只能显示10,似乎显示是在循环结束后才运行的,请高手赐教;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 10; i++)
{
label1.Text = i.ToString();
//延时
for (int j = 1; j <= 100000000; j++) { }
}
}
}
}[em18][em18]