ListView MouseUp事件 [英] ListView MouseUp Event

查看:71
本文介绍了ListView MouseUp事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在用户右键单击ListView中的

项目并且遇到一些看起来很奇怪的东西时显示一个ContextMenuStrip。

me。


最初填充ListView时,不会选择任何项目。当通过单击左或右按钮选择

第一项时,

SelectedIndexChanged事件将触发,但不会触发MouseUp事件。选择第一个

项目并点击另一个项目后,SelectedIndexChanged

和MouseUp事件都会触发。


因为我当单击

右键时,在MouseUp事件中调用Show()用于上下文菜单,当第一个

选择由右键选择时,不会显示上下文菜单点击一个项目。


任何人都可以告诉我,当第一次选择时,MouseUp事件是否正常,而不是
fire?有没有办法确保第一次选择显示

上下文菜单?


谢谢,

Tom

I am trying to display a ContextMenuStrip when a user right-clicks on an
item in a ListView and have encountered a something that seems strange to
me.

When the ListView is initially populated, no items are selected. When the
first item is selected by clicking either the left or right button, the
SelectedIndexChanged event fires but not the MouseUp event. After the first
item is selected and another item clicked on, both the SelectedIndexChanged
and MouseUp events fire.

Since I am calling Show() for the context menu in the MouseUp event when the
right button is clicked, no context menu is displayed when the first
selection is made by right-clicking an item.

Can anyone tell me if it is normal behavior for the MouseUp event not to
fire when the first selection is made? Is there any way to ensure the
context menu is displayed for the first selection?

Thanks,
Tom

推荐答案

4月8日,3:21 * pm,Tom Bean < tb ... @ newsgroup.nospamwrote:
On Apr 8, 3:21*pm, "Tom Bean" <tb...@newsgroup.nospamwrote:

我试图在用户右键单击

时显示ContextMenuStrip在ListView中的项目,遇到了一些看起来很奇怪的东西。


最初填充ListView时,没有选择任何项目。 *当通过单击左或右按钮选择

第一项时,

SelectedIndexChanged事件将触发,但不会触发MouseUp事件。 *在第一个

项目被选中并且点击了另一个项目后,SelectedIndexChanged

和MouseUp事件都会被激活。


自当点击

右键时,我在MouseUp事件中为上下文菜单调用Show(),当右边第一个

选择时,不会显示上下文菜单 - 点击一个项目。


任何人都可以告诉我,当第一次选择时,MouseUp事件的正常行为是不是为了
fire? *有没有办法确保第一次选择显示

上下文菜单?
I am trying to display a ContextMenuStrip when a user right-clicks on an
item in a ListView and have encountered a something that seems strange to
me.

When the ListView is initially populated, no items are selected. *When the
first item is selected by clicking either the left or right button, the
SelectedIndexChanged event fires but not the MouseUp event. *After the first
item is selected and another item clicked on, both the SelectedIndexChanged
and MouseUp events fire.

Since I am calling Show() for the context menu in the MouseUp event when the
right button is clicked, no context menu is displayed when the first
selection is made by right-clicking an item.

Can anyone tell me if it is normal behavior for the MouseUp event not to
fire when the first selection is made? *Is there any way to ensure the
context menu is displayed for the first selection?



我无法解答你关于MouseUp事件的问题,但是我想知道你怎么不使用buildt in通过设置ListView的ContextMenu属性来显示

a上下文菜单的方法?

I cannot qanswer your question about the MouseUp event, but I am
wondering how come you are not using the "buildt in" method of showing
a context menu by setting the ListView''s ContextMenu property?


坦率地说,我可能使用了MouseUp事件来显示上下文

菜单在一些特殊情况下并且习惯使用它。


上下文菜单的显示方式有一个显着的区别

设置listview属性时以及使用MouseUp

事件显示的方式。当我删除MouseUp事件处理程序并让listview显示

上下文菜单时,仅在选择项目时才会显示上下文菜单

点击鼠标按钮然后右键单击所选项目。在

中,它总是表现出当第一项是通过右键单击选择
时的方式。至少,让listview处理上下文

菜单提供一致的行为。


< za *** @ construction-imaging.comwrote in message

新闻:4e ********************************** @ a70g2000 hsh.googlegroups.com ...

4月8日下午3:21,Tom Bean < tb ... @ newsgroup.nospamwrote:
Quite frankly, I probably used the MouseUp event to show the the context
menu in some special case and just got in the habit of using it.

There is one notable difference between the way the context menu is shown
when the listview property is set and the way it shows using the MouseUp
event. When I removed the MouseUp event handler and let the listview show
the context menu, the context menu only appears when an item is selected
with a mouse button click and then the selected item is right-clicked. In
other words, it always behaves the way it does when the first item is
selected by a right-click. At least, letting the listview handle the context
menu offers consistent behavior.

<za***@construction-imaging.comwrote in message
news:4e**********************************@a70g2000 hsh.googlegroups.com...
On Apr 8, 3:21 pm, "Tom Bean" <tb...@newsgroup.nospamwrote:

我试图在用户右键单击

时显示ContextMenuStrip在ListView中的项目,遇到了一些看起来很奇怪的东西。


最初填充ListView时,没有选择任何项目。当通过单击左或右按钮选择

第一项时,

SelectedIndexChanged事件将触发,但不会触发MouseUp事件。选择了

第一个

项目并点击了另一个项目后,

SelectedIndexChanged

和MouseUp事件火。


因为我在MouseUp事件中为上下文菜单调用Show()时



右键是点击,当右键点击一个项目进行第一次

选择时,不会显示上下文菜单。


任何人都可以告诉我这是否是正常行为在第一次选择时,MouseUp事件不会发生爆炸吗?有没有办法确保第一次选择显示

上下文菜单?
I am trying to display a ContextMenuStrip when a user right-clicks on an
item in a ListView and have encountered a something that seems strange to
me.

When the ListView is initially populated, no items are selected. When the
first item is selected by clicking either the left or right button, the
SelectedIndexChanged event fires but not the MouseUp event. After the
first
item is selected and another item clicked on, both the
SelectedIndexChanged
and MouseUp events fire.

Since I am calling Show() for the context menu in the MouseUp event when
the
right button is clicked, no context menu is displayed when the first
selection is made by right-clicking an item.

Can anyone tell me if it is normal behavior for the MouseUp event not to
fire when the first selection is made? Is there any way to ensure the
context menu is displayed for the first selection?



我无法解答你关于MouseUp事件的问题,但是我想知道你怎么不使用buildt in通过设置ListView的ContextMenu属性来显示

a上下文菜单的方法?

I cannot qanswer your question about the MouseUp event, but I am
wondering how come you are not using the "buildt in" method of showing
a context menu by setting the ListView''s ContextMenu property?


嗨Tom,


感谢您的及时回复!


我在VS2008版本9.0.21022.8 RTM中执行了另一项测试,但仍然没有重现

问题。


运行应用程序的操作系统版本是什么?您可以尝试在另一台机器上运行该应用程序,以查看问题是否仍然存在。


此致

Linda Liu

微软在线社区支持


让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


此帖子按原样提供。没有保证,也没有授予任何权利。
Hi Tom,

Thank you for your prompt reply!

I performed another test in VS2008, version 9.0.21022.8 RTM, but still
didn''t reproduce the problem.

What''s the OS version on which you run the application? You may have a try
running the application on another machine to see if the problem still
exists.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于ListView MouseUp事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆