ListView 通过用户拖动调整大小 (VB.net)

发布于 2024-08-14 05:00:15 字数 576 浏览 4 评论 0原文

我正在将公司的 VB6 程序转换为 VB.net,但我遇到了另一个愚蠢的小障碍。

旧程序有一个 ListView 停靠在应用程序屏幕的左侧。用户可以将光标放在 ListView 的右侧部分,光标将变成 SizeWE 箭头,然后他们可以拖动它,这将调整 ListView 的大小。

我正在尝试重新创建这个。据我所知,没有任何属性称为“可调整大小”,或者至少没有任何内容向我弹出。我不相信它是在代码中完成的。

我是否缺少某项财产?如果没有,是否有一种简单的方法可以在代码中执行此操作? (即,是否有一个事件可以让我的生活变得更轻松)

我正在使用 Visual Studio 2008。

请原谅任何菜鸟; .NET 对我来说还很陌生,而且我是整个公司唯一的程序员。我才毕业一年.. 提前致谢!

编辑:我知道它在上一个程序中是如何完成的(一旦你提出问题,你似乎总是能找到它,不是吗?)。旧程序有一个不可见的图片,只有几个像素宽,当鼠标悬停在上面时,光标会更改为 SizeWE。然后,您可以拖动该不可见的图片,这将触发一个事件,然后该事件将更改 ListView 的大小。这看起来相当复杂。我的问题仍然存在:是否有更好的方法来处理这种拖动和调整大小?

I am converting my company's VB6 program over to VB.net and I have hit another stupid little roadblock.

The old program had a ListView docked to the left side of the application screen. The user could place the cursor over the right portion of the ListView, the cursor would turn into the SizeWE arrows, then they could drag it, which would resize the ListView.

I am trying to recreate this. As far as I can tell there is no Property called "Resizable," or at least nothing is popping out to me. I do not believe that it is being done in the code.

Is there a property I am missing? If not, is there an easy way to do this within the code? (ie. is there a event that would make my life easier)

I am using Visual Studio 2008.

Please forgive any noobness; .NET is still very new to me and I am the only programmer in the whole company. I am only a year out of school..
Thanks in advance!

Edit: I see how how it was done in the previous program (you always seem to find it once you ask the question, don't you?). The old program had a invisible picture that was only a few pixels wide that when hovered over would change the cursor to SizeWE. You could then drag that invisible picture and that would hit an event that would then change the size of the ListView. This seems rather convoluted. My question still stands: Is there a better way to handle this dragging and resizing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心是晴朗的。 2024-08-21 05:00:15

您应该考虑使用 Splitter< /code>控件,或使用 SplitContainer 控件。

如果您使用 Splitter,最简单的成功方法是:

  • ListView 控件添加到表单,将 Dock 属性设置为 Left
  • 添加将 Splitter 控件添加到窗体,将 Dock 属性设置为 Left
  • Panel 控件添加到窗体,设置将 Dock 属性设置为 Fill

这将为您提供一个视图,用户可以在其中调整 ListViewPanel 的大小(您可以在其中放置所需的任何其他控件)将使用任何可用空间。如果控件的行为不符合您的要求(例如,如果拆分器没有达到您期望的位置),请使用 Format ->;订单->按 ListViewSplitterPanel 的顺序在控件上发送到后面命令。

You should look into using either a Splitter control, or to use the SplitContainer control.

If you use a Splitter, the easiest way to succeed is this:

  • Add the ListView control to the form, set the Dock property to Left
  • Add the Splitter control to the form, set the Dock property to Left
  • Add a Panel control to the form, set the Dock property to Fill

This will give you a view where the user can resize the ListView and the Panel (in which you can place any other controls you need) will use whatever space is available. If the controls don't behave as you want them (if the Splitter does not end up where you expect for instance), use the Format -> Order -> Send to back command on the controls in the order ListView, Splitter and Panel.

本宫微胖 2024-08-21 05:00:15

使用 SplitContainer 可以让您轻松地做到这一点。
替代文本 http://img30.imageshack.us/img30/6568/captureoq.jpg< /a>

Using a SplitContainer will allow you to do this easily.
alt text http://img30.imageshack.us/img30/6568/captureoq.jpg

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文