处理列表框中的按键 [英] Handling key presses in a list box

查看:74
本文介绍了处理列表框中的按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的项目中有一个与列表框控件相关的要求.我已将文件名添加到列表框中.我按如下方式处理了删除"和输入"键.
删除-删除带有用户确认的条目(使用是"和否"按钮)
Enter-打开文件(列表框上的选定条目)

现在,如果我选择任何项目并按删除",则会弹出一条确认消息,突出显示是".然后我按"Enter".所选项目被删除,但另一个项目正在打开. (这是因为我也已经处理过"Enter"键). 我需要避免这种情况(因为这分散了我的基本工作流程)

我浏览了Internet上的各种主题,但未能实现.
有人可以帮我吗?

谢谢和问候,
YKK Reddy

Hi All,

I have a requirement in my project related to a list box control. I have added file names to the list boxes. I handled "Delete" and "Enter" keys as follows.
Delete - Delete the entry with confirmation from user (with Yes and No buttons)
Enter - opens the file (selected entry on the list box)

Now if i select any item and press "Delete", a confirmation message pops up with "Yes" focused. And then i press "Enter". The selected item gets deleted but another item is getting opened. (this is because i have handled "Enter" key also). I need to avoid this (as this is distracting my basic workflow)

I browsed through various topics on internet but could not achieve this.
Can anyone help me out ?

Thanks and Regards,
YKK Reddy

推荐答案

经过多次试验,我自己解决了该问题.
我同时处理了KeyDownPreviewKeyDown事件.
KeyDown事件中,我正在执行所有实现,而在PreviewKeyDown中我什么也不做.

方法OnPreviewKeyDown()事件中的代码为空.

这解决了我的问题.
After many trials i solved it myself.
I handled both KeyDown and PreviewKeyDown Events.
in KeyDown Event, i am doing all the implementation and in PreviewKeyDown i am doing nothing.

The code in method OnPreviewKeyDown() event is blank.

This solves my problem.


这篇关于处理列表框中的按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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