简体   繁体   English

恢复窗口后(最小化后),不显示ToolStripStatusLabel

[英]ToolStripStatusLabel is not displayed after the window be restored(after minimize)

I have a simple StatusStrip with one ToolStripStatusLabel in it. 我有一个带有一个ToolStripStatusLabel的简单StatusStrip。 Text in label can be quite long, so I have prefered to display it cutted. 标签中的文字可能会很长,因此我更喜欢将其裁切显示。
I have set ToolStripStatusLabel properties: Spring=true and TextAlign=MiddleLeft . 我设置了ToolStripStatusLabel属性: Spring=trueTextAlign=MiddleLeft I didn't want to set StatusStrip's property LayoutStyle = ToolStripLayoutStyle.Flow , because with ToolStripLayoutStyle.Flow the Text will be overridden with triangle(for resizing). 我不想设置StatusStrip的属性LayoutStyle = ToolStripLayoutStyle.Flow ,因为使用ToolStripLayoutStyle.Flow ,文本将被三角形覆盖(以调整大小)。 在此处输入图片说明

The Text property is set directly after InitializeComonents() and is displayed as expected - cutted. 直接在InitializeComonents()之后设置Text属性,并按预期显示-剪切。
If I do minimize(to taskbar) and then restore the window, the text will not be displayed at all. 如果我最小化(到任务栏),然后还原窗口,则文本将不会显示。 If I make window wider I can see the text, and if I bring the window to the initial size I still can see the text, cutted as expected. 如果将窗口加宽,则可以看到文本,如果将窗口调整为初始大小,仍可以看到文本,并按预期切割。

I have and will post my solution, but I would ask you, whether you have any elegant one? 我已经并且会发表我的解决方案,但是我会问你,你是否有一个优雅的解决方案?

The solution I have found is quite simple. 我发现的解决方案非常简单。 Just handle the window's restore event(there is no such event, but there is a workaround: Is there an event raised in C# when a window is restored? ) and reset the text in ToolStripStatusLabel: 只需处理窗口的还原事件(没有此类事件,但是有一种解决方法: 还原窗口时,C#中会引发一个事件吗? )并在ToolStripStatusLabel中重置文本:

var txt = tslabel.Text;
tslabel.Text = " ";
tslabel.Text = txt;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM