我有一个WinForms程序,其中包含一个 button
,一个 statusStrip
和一个在那个 statusStrip
中的 toolStripStatusLabel
。如果我点击这个按钮并运行此代码:
private void button1_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Text = "Test";
System.Threading.Thread.Sleep(5000);
}
当线程在休眠期间,toolStripStatusLabel
的文本内容不会立即更新。我该如何让它立即更新,然后再使线程休眠?
toolStripStatusLabel1.Update()
。 - P. KouvarakisToolStripStatusLabel
不是一个Control
。你必须在工具栏本身(statusStrip
?)上调用Update()
。 - P. Kouvarakis