Cant Intercept DEL Key ..无法识别...... [英] Cant Intercept DEL Key .. not recognized ...

查看:52
本文介绍了Cant Intercept DEL Key ..无法识别......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计,


问题是,在我的一个控件上,DEL键不会在

文本框中工作。我在我的应用程序中有这种不同的控件这个

是唯一一个DEL Key不会完成他的工作。 BACKSPACE和rightclick

菜单删除也可以。似乎DEL Key没有发生任何事件...我想在我的项目中插入以下代码来检查这个。没有mehthod调用如果

DEL键命中...这个问题的任何解决方案或想法?

不能说...这个tabcontrol上的用户你不能使用DEL如果它工作在

所有其他部分:(


private void OnKeyDown(对象发送者,KeyEventArgs AArgs)


{


base.OnKeyDown(AArgs);


System.Windows.Forms.Keys LKey =

System.Windows .Forms.Keys.KeyCode&

AArgs.KeyCode;


开关(LKey)


{


案例System.Windows.Forms.Keys.Delete:


MessageBox.Show(" DEL Key!");


休息;


}


}

Hi Folks,

Problem is, that on one of my controls the DEL key wont work in
textboxes. i have different controls of this kind in my app and this
is the only one the DEL Key wont do his job. BACKSPACE and rightclick
menu delete works either. seems the DEL Key fires no event ... i
insert following code in my project to check this. no mehthod call if
DEL key hit ... any solution or idea for this problem ?
cant say ... users on this tabcontrol you cant use DEL if it works in
all other parts :(

private void OnKeyDown(object sender,KeyEventArgs AArgs)

{

base.OnKeyDown(AArgs);

System.Windows.Forms.Keys LKey =
System.Windows.Forms.Keys.KeyCode &
AArgs.KeyCode;

switch (LKey)

{

case System.Windows.Forms.Keys.Delete :

MessageBox.Show("DEL Key!");

break;

}

}

推荐答案

好吧,首先我会调用base.OnKeyDown ...在我的代码之后。不是我

实际上是在调用它,它无论如何都会被调用。


其次,使用位掩码用于提取KeyValue以获得

KeyCode。你已经拥有AArgs.KeyCode中的KeyCode因此没有

需要使用位掩码。


第三,代码有效且文本框会触发事件删除

键所以不知何故你的代码与它无关。


-

使用M2,Opera'革命性的电子邮件客户端: http://www.opera.com/m2/
Well, First I would call base.OnKeyDown... after my code. Not that I
actually call it at all, it gets called anyway.

Second, using the bitmask is for extracting KeyValue to obtain the
KeyCode. You already have the KeyCode in AArgs.KeyCode so there is no
need to use the bitmask.

Third, the code is valid and a textbox does fire an event on the delete
key so somehow your code isn''t tied to it.

--
Using M2, Opera''s revolutionary e-mail client: http://www.opera.com/m2/


Dan,


您发布的代码应该拦截删除密钥。

我的一个想法是,KeyUp事件被错误地添加了。确保

以下代码行添加到您InitializeComponent()

方法。


this.textBox1.KeyDown + = new

System.Windows.Forms.KeyEventHandler(this.OnKeyDow n);


如果这没有帮助,如果你可以发帖或发电子邮件我是你的来源

表格我愿意帮助解决这个问题。


Glen Jones MCSD
da **** @ oxigem.com (Dan K.)在留言新闻中写道:< cf ************ **************@posting.google。 com> ...
Dan,

Your code you posted should be intercepting the delete key.

One idea my be that the KeyUp event was added incorrectly. Make sure
the following line of code was added to you InitializeComponent()
method.

this.textBox1.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.OnKeyDow n);

If this doesn''t help, if you could post or email me your source for
the form I would be willing to help figure out the problem.

Glen Jones MCSD
da****@oxigem.com (Dan K.) wrote in message news:<cf**************************@posting.google. com>...
嗨伙计,

问题是,在我的一个控件上DEL键不会在
文本框中工作。我在我的应用程序中有这种不同的控件,这是唯一一个DEL Key不会完成他的工作。 BACKSPACE和rightclick
菜单删除工作。似乎DEL Key没有发生任何事件......我在我的项目中插入以下代码来检查这一点。没有mehthod调用如果
DEL键命中...这个问题的任何解决方案或想法?
不能说...这个tabcontrol上的用户你不能使用DEL如果它在所有其他部分工作:(

private void OnKeyDown(对象发送者,KeyEventArgs AArgs)



base.OnKeyDown(AArgs);

System.Windows.Forms.Keys LKey =
System.Windows.Forms.Keys.KeyCode&
AArgs.KeyCode;

开关(LKey)

案例System.Windows.Forms.Keys.Delete:

MessageBox.Show(" DEL Key!");

break;

}

}
Hi Folks,

Problem is, that on one of my controls the DEL key wont work in
textboxes. i have different controls of this kind in my app and this
is the only one the DEL Key wont do his job. BACKSPACE and rightclick
menu delete works either. seems the DEL Key fires no event ... i
insert following code in my project to check this. no mehthod call if
DEL key hit ... any solution or idea for this problem ?
cant say ... users on this tabcontrol you cant use DEL if it works in
all other parts :(

private void OnKeyDown(object sender,KeyEventArgs AArgs)

{

base.OnKeyDown(AArgs);

System.Windows.Forms.Keys LKey =
System.Windows.Forms.Keys.KeyCode &
AArgs.KeyCode;

switch (LKey)

{

case System.Windows.Forms.Keys.Delete :

MessageBox.Show("DEL Key!");

break;

}

}



抱歉迟到的答案......最近几周正在度假:)


问题仍然存在...


在我看来它不是keydown的实现事件

因为这个实现只是检查DEL Key是否触发

事件的测试。

自然DEL功能(删除内容)不要在这个

控件上完成他的工作。测试应该只显示原因。
但它仍然不清楚。还有什么进一步的想法吗?


格伦我还能告诉你这个控件的来源吗?
sorry for the late answer ... was on holiday the last weeks :)

problem still active ...

at my view its not the implemententation of the of the keydown event
cause this implementation was only a test to check if DEL Key fires an
event.
the naturally DEL Function (delete content) dont do his job on this
control. the test should only show why.
but its still not clear for me. any further idea ?

glen can i still send you the source of this control to check ?


这篇关于Cant Intercept DEL Key ..无法识别......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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