列表框宽度大小取决于文本长度
我的应用程序有一个带有列表框的窗口,其中填充了随时间变化的文本,因此列表框条目可以有多个长度。
我想让窗口和列表框宽度根据列表框条目长度(以字符数为单位)动态更改。
举个例子,如果我的列表框有多个条目,并且最大长度为 30 个字符,我想让窗口及其列表框的宽度大于最大长度为 20 个字符的窗口。
最好的方法是什么?
My application has a window with a ListBox inside which is filled with text that changes over time, therefore Listbox entries can have several length.
I'd like to make the window and the listbox width to change dynamically dependent on the listbox entries length (in number of characters).
As an example, if my listbox has several entries and the maximum lenght is 30 characters i want to make the window and its listbox larger in width than one window that which maixum lenght is 20 characters.
What is the best way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这样的事情:
Try something like this:
您使用什么编程平台?我猜是.NET 和VB。
放入一个方法来检查列表的内容并根据需要更改框和窗口的大小:
希望这为您提供了一个不错的起点。
What programming platform are you using? I'm guessing .NET and VB.
Put in a method to examine the contents of the list and change the size of the box and window as required:
Hope this gives you a decent starting point.
试试这个:
Try this: