Form直接访问toolStripStatusLabel的属性,不能范围。报错。后来参考
http://stackoverflow.com/questions/29829936/how-to-update-toolstripstatuslabel-text-from-a-method-passing-all-the-controls-o
https://bytes.com/topic/c-sharp/answers/271395-mdi-statusstrip
才知道:
The Controls
collection is not used on the ToolStrip
and ToolStripContainer
. You should use Items
instead
所以应该这样用:
((StatusStrip)this.TopLevelControl.Controls["statusStrip1"]).Items["toolStripStatusLabel2"].Text = "Help"