我想我会尝试回复这个问题,因为它已经有一段时间没有得到答复:-(我认为这可以做到,但我还是说它需要用.NET控件来完成。
我会接近它是创建一个.NET面板,它是用户控件的基础,然后创建一个KeyPress事件。我尝试制作一个比我想象的更难的快速演示 - 做一个网络搜索似乎这个
是一个已知的问题,你需要调用Panel.Focus()(或你正在使用的任何控件 - 它可能是一个带有4向箭头的标签......)我发现我需要调用它
开始以及每次按下一个键(可能是焦点丢失到对话框中)。我确信这可以改进,但至少它说明我有可能发现一个字符键同时触发KeyPress和KeyDown
事件,而箭头键(或功能键)只被后者困住.HTH迈克
以上来自于谷歌翻译
以下为原文
I thought I'd make an attempt at a reply for this as it has been unanswered for some time :-(
I think this can be done, but I would also say that it needs to be done with a .NET control. The way I would approach it is to create a .NET panel which is the basis of the user control and then create a KeyPress Event. I tried making a quick demo which was a bit more difficult than I had thought - doing a web search it seems this is a known issue and that you need to call
Panel.Focus()
( or whatever control you're using - it could be a label with a 4-way arrow on it... )
I found I needed to call it at the start and also each time a key was pressed ( presumably the focus was lost to the dialog box ). I'm sure this could be improved but at least it demostrates that it is possible
I also discovered that a character key triggered both KeyPress and KeyDown events, whereas an arrow key ( or a function key ) is only trapped by the latter.
HTH
Mike
附件
我想我会尝试回复这个问题,因为它已经有一段时间没有得到答复:-(我认为这可以做到,但我还是说它需要用.NET控件来完成。
我会接近它是创建一个.NET面板,它是用户控件的基础,然后创建一个KeyPress事件。我尝试制作一个比我想象的更难的快速演示 - 做一个网络搜索似乎这个
是一个已知的问题,你需要调用Panel.Focus()(或你正在使用的任何控件 - 它可能是一个带有4向箭头的标签......)我发现我需要调用它
开始以及每次按下一个键(可能是焦点丢失到对话框中)。我确信这可以改进,但至少它说明我有可能发现一个字符键同时触发KeyPress和KeyDown
事件,而箭头键(或功能键)只被后者困住.HTH迈克
以上来自于谷歌翻译
以下为原文
I thought I'd make an attempt at a reply for this as it has been unanswered for some time :-(
I think this can be done, but I would also say that it needs to be done with a .NET control. The way I would approach it is to create a .NET panel which is the basis of the user control and then create a KeyPress Event. I tried making a quick demo which was a bit more difficult than I had thought - doing a web search it seems this is a known issue and that you need to call
Panel.Focus()
( or whatever control you're using - it could be a label with a 4-way arrow on it... )
I found I needed to call it at the start and also each time a key was pressed ( presumably the focus was lost to the dialog box ). I'm sure this could be improved but at least it demostrates that it is possible
I also discovered that a character key triggered both KeyPress and KeyDown events, whereas an arrow key ( or a function key ) is only trapped by the latter.
HTH
Mike
附件
举报