怪异的表格事件发生 [英] Weird Form Event Occurances

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

问题描述




不知道是否有人可以对此投光......

我有一个相当复杂的C#WinForm(其中)一个文本框和一个

按钮。

TextBox有为KeyUp和KeyDown声明的事件,按钮有一个简单的
点击事件。


在某些情况下(还没有完全解决它们的问题,

但它涉及打开和关闭子表格)。按下文本框中

光标的ENTER会导致按钮点击事件触发...... !!

任何人都可以提出任何关于我可以开始排除故障的建议

这个?


谢谢,


ChrisM

Hi,

Don''t know if anyone can cast any light on this...
I have a fairly complex C# WinForm with (amongst other) a text box and a
button.
The TextBox has events declared for KeyUp and KeyDown, the button has a
simple Click event.

Under certain circumstances (haven''t worked out exactly what they are yet,
but it involves opening and closing a sub form). Pressing ENTER with the
cursor in the textbox causes the Button Click event to fire...!!
Can anyone make ANY suggestions as to where I could start troubleshooting
this?

Thanks,

ChrisM

推荐答案

Chris,


我必须看到一个样本才能相信这一点。我想也许你可能会做一些你可能不知道的事情导致代码执行的结果是

执行。


你能发一份工作样本吗?


-

- Nicholas Paldino [.NET / C#MVP]

- < a href =mailto:mv*@spam.guard.caspershouse.com> mv*@spam.guard.caspershouse.com


" ChrisM" < CH ************** @ suedeyahoo.com>在消息中写道

新闻:OI ************** @ TK2MSFTNGP05.phx.gbl ...
Chris,

I''d have to see a sample to believe this. I think that maybe you might
be doing something you might not be aware of which results in the code being
executed.

Can you post a working sample?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:OI**************@TK2MSFTNGP05.phx.gbl...

不知道是否有人可以对此发表任何看法...
我有一个相当复杂的C#WinForm,其中包括一个文本框和一个
按钮。 TextBox具有为KeyUp和KeyDown声明的事件,该按钮具有简单的Click事件。

在某些情况下(还没有完全解决它们的问题,
但它涉及打开和关闭子表单)。用文本框中的
光标按ENTER键会导致按钮点击事件触发...... !!
任何人都可以就我在哪里开始排除故障提出任何建议
这个?

谢谢,

ChrisM
Hi,

Don''t know if anyone can cast any light on this...
I have a fairly complex C# WinForm with (amongst other) a text box and a
button.
The TextBox has events declared for KeyUp and KeyDown, the button has a
simple Click event.

Under certain circumstances (haven''t worked out exactly what they are yet,
but it involves opening and closing a sub form). Pressing ENTER with the
cursor in the textbox causes the Button Click event to fire...!!
Can anyone make ANY suggestions as to where I could start troubleshooting
this?

Thanks,

ChrisM





" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:************** @ TK2MSFTNGP02.phx.gbl ...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Of**************@TK2MSFTNGP02.phx.gbl...
Chris,
我必须看到一个样本才能相信这一点。我想也许你可能正在做一些你可能不知道哪些会导致代码执行的结果。

你能发布一份工作样本吗?
Chris,

I''d have to see a sample to believe this. I think that maybe you might
be doing something you might not be aware of which results in the code
being executed.

Can you post a working sample?




我确定你是对的,但我检查了所有我能想到的东西,并且

那里有''没有其他任何调用myButton_Click ...

代码。我不能发布一个例子,因为它是一个相当可观的应用程序的一个组成部分,而且我认为我不能用
$ b $提取代码。 b问题,但不包括大部分应用程序的其余部分...


多一点实验表明

的KeyDown事件当TextBox与

按钮点击事件''交叉连接'时,TextBox停止接收Enter键。


我会看看我是否可以创建一个小工作这个问题的演示,但我不是很有希望。


无论如何,谢谢你的回复。


Chris。



I''m sure you''re right, but I''ve checked all the things I can think of, and
there''s nothing else that calls the myButton_Click...
code. I can''t really post an example as it is an integral part of a fairly
sizable application, and I don''t think I can extract the code with the
problem without including most of the rest of the application...

A little more experimentation has shown that the ''KeyDown'' event of the
TextBox stops receiving the Enter key when it becomes ''crosswired'' with the
Buttons Click event.

I will see if I can create a small working demo of the problem, but I''m not
too hopeful.

Thanks for your reply anyway.

Chris.




" ChrisM" < CH ************** @ suedeyahoo.com>在消息中写道

新闻:O8 ************** @ TK2MSFTNGP02.phx.gbl ...

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:O8**************@TK2MSFTNGP02.phx.gbl...

" ;圣油" < CH ************** @ suedeyahoo.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP05.phx.gbl ...

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>在消息新闻中写道
:************** @ TK2MSFTNGP02.phx.gbl ...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:Of**************@TK2MSFTNGP02.phx.gbl...
Chris,
我必须看到一个样本才能相信这一点。我想也许你可能会做一些你可能不知道导致代码执行的结果。

你能发布一个工作样本吗?
Chris,

I''d have to see a sample to believe this. I think that maybe you
might
be doing something you might not be aware of which results in the code
being executed.

Can you post a working sample?



我确定你是对的,但我已经检查了所有我能想到的东西,

这里有没有其他任何调用myButton_Click ...
代码。我不能发布一个例子,因为它是
相当大的应用程序的一个组成部分,我不认为我可以用
问题提取代码而不包括大部分应用程序的其余部分...

稍​​微进行一些实验表明,
TextBox的'KeyDown'事件在变为''crosswired时停止接收Enter键''
按钮Click事件。

我会看看是否可以创建一个小问题的工作演示,但我不是太有希望了。

感谢您的回复。

Chris。



I''m sure you''re right, but I''ve checked all the things I can think of,
and
there''s nothing else that calls the myButton_Click...
code. I can''t really post an example as it is an integral part of a
fairly
sizable application, and I don''t think I can extract the code with the
problem without including most of the rest of the application...

A little more experimentation has shown that the ''KeyDown'' event of the
TextBox stops receiving the Enter key when it becomes ''crosswired'' with
the
Buttons Click event.

I will see if I can create a small working demo of the problem, but I''m
not
too hopeful.

Thanks for your reply anyway.

Chris.



好的,

实际上并没有像我想象的那样重现问题......
我附上了一个包含示例项目的Zip文件,该文件正好显示了我所遇到的问题我有。

有三种形式:
Form1 - MDI父表格。
FormMain - 表示菜单表格的子表单。
FormDemo - 另一个表示问题形式的子表单。

要重现问题:
1)运行应用程序,您应该获得包含
菜单表单的父表单。
2)单击按钮 - 应该拉出另一个子窗体。
3)确保焦点位于文本框中并按ENTER键 - 应该收到相应的消息。
4)单击按钮 - 应该显示相应的消息,并且菜单表格将显示在前面。
5)关闭菜单表格(点击顶部右上角的X)
6)确保焦点在文本框并按ENTER键。
7)说明......!

如果您对附件有任何问题,并准备提供帮助,请通过此地址给我发送电子邮件我可以给你发电子邮件代码。
(从我的电子邮件地址中删除Blue和Suede回复)。

谢谢,

Chris。



OK,

It wasn''t actually as hard to reproduce the problem as I thought...
I have attached a Zip file containing a sample project that shows exactly
the problem I''m having.

There are Three forms:
Form1 - An MDI Parent Form.
FormMain - A child form which represents a Menu Form.
FormDemo - Another child form that represents the form with the problem.

To reproduce the problem:
1) Run the application and you should get the Parent form containing the
Menu Form.
2) Click the button - should pull up the other child form.
3) Make sure focus is in the text box and press ENTER - should get
appropriate message.
4) Click the button - should appropriate message, and Menu Form comes to
front.
5) CLOSE Menu Form (Click on X in Top RH Corner)
6) Make sure focus is in the Textbox and press ENTER.
7) Explain that...!

If you have any problems with the attachment, and are prepared to help,
email me on this address and I can email you the code.
( Remove Blue and Suede from my email address to reply).

Thanks,

Chris.




顺便说一句,这一切都在VS2003 / Framework 1.1中运行


Chris。



btw, this is all running in VS2003 / Framework 1.1

Chris.


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

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