ListView 通过用户拖动调整大小 (VB.net)
我正在将公司的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该考虑使用
Splitter< /code>
控件,或使用
SplitContainer
控件。如果您使用 Splitter,最简单的成功方法是:
ListView
控件添加到表单,将Dock
属性设置为Left
Splitter
控件添加到窗体,将Dock
属性设置为Left
Panel
控件添加到窗体,设置将Dock
属性设置为Fill
这将为您提供一个视图,用户可以在其中调整
ListView
和Panel
的大小(您可以在其中放置所需的任何其他控件)将使用任何可用空间。如果控件的行为不符合您的要求(例如,如果拆分器没有达到您期望的位置),请使用Format ->;订单->按
命令。ListView
、Splitter
和Panel
的顺序在控件上发送到后面You should look into using either a
Splitter
control, or to use theSplitContainer
control.If you use a Splitter, the easiest way to succeed is this:
ListView
control to the form, set theDock
property toLeft
Splitter
control to the form, set theDock
property toLeft
Panel
control to the form, set theDock
property toFill
This will give you a view where the user can resize the
ListView
and thePanel
(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 theFormat -> Order -> Send to back
command on the controls in the orderListView
,Splitter
andPanel
.使用 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