添加多选功能(Java 开发人员学习 C#)

发布于 2024-07-25 09:16:55 字数 226 浏览 4 评论 0原文

我正在编写我继承的一段代码,并试图将其从只能选择一行扩展到能够选择多行。

本质上,我正在处理的项目显示得像一个数据表。 它包含“OnSelectItem”和“OnMouseDown”方法,其中“OnMouseDown”检查单击是鼠标右键单击还是鼠标左键单击。

一般来说,支持多选功能的功能是如何实现的? 除了按住特定键之外,是否还通过识别鼠标点击来处理它,或者是否有其他方法来实现此类功能?

I'm working on a piece of code that I inherited and am trying to expand it from only being able to select one row to being able to select multiple rows.

Essentially, the item I'm working with displays like a data table. It contains methods for "OnSelectItem" and "OnMouseDown", with "OnMouseDown" checking to see if the click is right mouse button click or a left mouse button click.

Generally, how is functionality to support the ability to support Multi Select implemented? Is it handled through recognization of the mouse clicks in addition to holding down particular keys or is there a different way to implement this type of functionality?

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

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

发布评论

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

评论(2

零度° 2024-08-01 09:16:55

您的评论表明您正在使用自定义控件。 因此,适用于 Microsoft 提供的一般控件的答案可能根本不起作用。

您应该能够使用已列出的事件来处理此自定义控件中的多选功能。

作为示例,您可以查看 CheckedListBox 控件。 它的每一行前面都有一个复选框。 如果选中该框,则该行被“选择”。 如果这不是您要寻找的选择类型,那么您可以在详细信息模式下查看 ListView 控件。 它允许您设置选项,让用户突出显示多行,使用 CTRL 和/或 SHIFT 修改鼠标单击影响选择的方式。

Your comments indicate that you're working with a custom control. So, answers that apply to general Microsoft-supplied controls may not work at all.

You should be able to use the events you've listed already to handle multi-select features in this custom control.

As an example, you could look at the CheckedListBox control. It has a checkbox in front of every row. If the box is checked, that row is "selected". If that's not the type of selection you're looking for, then you can look at the ListView control in Detail mode. It allows you to set options that let the user highlight multiple rows, using CTRL and/or SHIFT to modify the way the mouse-click affects selection.

栩栩如生 2024-08-01 09:16:55

就多选而言,从我的角度来看,除了鼠标单击之外,它还需要键盘支持

1)在控制中,如果我们按 Shift 键,然后按向上或向下箭头键,则也可以选择行

2)我们也可以通过复选框列实现多选功能,我不确定这在您的情况下是否可行

3)还有固定列的基本原理,在鼠标单击该列时,整行都会被选中

As far as multi select is concerned from my point of view it also requires key board support in addition to mouse click

1) In Controls if we press shift key and then press up or down arrow key then also row get selected

2) We can also implement multi select functionality by checkbox column, i am not sure this is possible or not in your case

3) There is also fundamental of Fixed Column, on mouse click of that column entire row is getting selectd

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