制作带标签的可滚动控件列表的最简单方法是什么?
使用 C++/CLI 和 Windows 窗体,我尝试制作一个简单的可滚动标记文本控件列表,作为显示某些数据字段的方式。我在使 TableLayoutPanel
可滚动时遇到问题 - 我尝试过的每种属性组合似乎都会导致一些非常特殊的副作用。
所以我有两个问题:
- 这是最好的方法吗?
- 如果这是一个合理的方法,我应该对表格布局面板应用什么神奇的设置组合才能使其发挥作用?
Using C++/CLI and Windows Forms, I'm trying to make a simple scrollable list of labelled text controls as a way of displaying some data fields. I'm having trouble making a TableLayoutPanel
scrollable - every combination of properties I've tried seems to result in some really peculiar side effects.
So I have two questions:
- Is this the best way to do it.
- If it is a reasonable approach, what magic combination of settings should I apply to the table layout panel to make it play ball?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TLP 未设计为可滚动的。您将需要一个 FlowLayoutPanel。
请注意,您通常会得到相当多的窗口,这将使您的程序变得非常慢。当表单中的控件超过 50 个时,绘制会变得明显滞后。最好的解决方案是一个可以显示多个项目但只需要一个窗口句柄的控件。 ListBox、带有 View = Details 的 ListView、DataGridView 都是可以执行此操作的控件的很好示例。他们还允许自定义绘画来调整他们的视图,这样你就可以按照你想要的方式得到它。
TLP is not designed to be scrollable. You'll want a FlowLayoutPanel.
Beware that you'll usually end up with a rather large number of windows which will make your program very slow. Painting becomes noticeably laggy when you get more than about 50 controls in a form. The best solution is a control that can display multiple items but only needs a single Window handle. ListBox, ListView with View = Details, DataGridView are good examples of controls that can do this. They also allow custom painting to tweak their view so you can get it just the way you want it.