处理单击ComboBox中项目上的事件 [英] Handle Click Event on Item in a ComboBox

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

问题描述

有没有人知道任何事件或事件序列,以便在用户单击ComboBox中的项目时能够处理?目前,我看到的唯一的事件,从ComboBox在WinForms中被触发的是SelectedIndexChanged或SelectedValueChanged。这些事件的问题是,它们也在许多其他scenerios下被触发,例如当用户按下向上或向下箭头(即使ComboBox未打开)。

Does anyone know of any event or sequence of events to be able to handle when a user clicks an item in a ComboBox? Currently the only events that I see being fire from ComboBox within WinForms is SelectedIndexChanged or SelectedValueChanged. The problem with these events is that they are also fired under many other scenerios such as when the user presses up or down arrow (even if the ComboBox is not open).

ComboBox.SelectedIndexChanged += (o, e) => Console.WriteLine("ComboBox_SelectedIndexChanged");
ComboBox.SelectedValueChanged += (o, e) => Console.WriteLine("ComboBox_SelectedValueChanged");

任何想法?

推荐答案

如果您询问用户何时在ComboBox中单击某个项目进行选择,您可以使用 ComboBox.SelectionChangeCommitted 事件。

If you are asking about when the user clicks an item in the ComboBox to select it, you can use the ComboBox.SelectionChangeCommitted event.

这篇关于处理单击ComboBox中项目上的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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