2017-04-17 147 views
-1

我有一个WinForms程序,该程序在该statusStrip中有buttonstatusStriptoolStripStatusLabel。如果我按一下按钮,这样运行:立即更新toolStripStatusLabel

private void button1_Click(object sender, EventArgs e) 
{ 
    toolStripStatusLabel1.Text = "Test"; 

    System.Threading.Thread.Sleep(5000); 
} 

然后toolStripStatusLabel的文本不更新后才线程完成睡觉。我如何让它立即更新,然后睡觉线程?

+0

使用'toolStripStatusLabel1.Update()'睡眠之前。 –

+0

@ P.Kouvarakis我在https://msdn.microsoft.com/zh-cn/library/system.windows.forms.toolstripstatuslabel(v=vs.110).aspx – derekantrican

+1

中看不到任何此类方法对不起,您是正确的.'ToolStripStatusLabel'不是'Control'。您必须在工具栏本身调用'Update()'('statusStrip'?)。 –

回答

0

正如P. Kouvarakis说,解决办法是这样的:

toolStripStatusLabel1.Text = "Test"; 
statusStrip1.Update(); 
System.Threading.Thread.Sleep(5000);