我已经实现了 UserControl
带有文字 Label
.我想在调整控件宽度时调整控件高度,使整个文本始终可见,如图所示:
我已经自定义了 WinForms Label
计算TextBounds
标签(文本所需的矩形),我引发了一个名为 TextBoundsChanged
的事件这表明文本矩形大小已更改(请注意,在调整标签大小时始终会引发此事件)。
这是可行的:我收到事件,然后更新我的控件高度,但控件的高度实际上没有改变!!
我怀疑 TextBoundsChanged
UserControl
时引发事件正在调整大小。 UserControl
也正在调整大小,所以我担心 WinForms 在调整大小时会忽略控件高度更新。
我说的对吗?有人知道如何解决这个问题吗?
提前致谢。
EDIT: The user control not only show text. This is only a simplified sample. So, my user control needs to vertically grow when I reduce the width, in order to show the whole text in the label. the label is not a custom winforms label, because it renders HTML content. Also, I'm using .NET1, so the word wrap property is not available for me
最佳答案
关于C#:调整大小时无法更新控件高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5001783/