473,748 Members | 4,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird Form Event Occurances

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
Jun 21 '06 #1
11 1780
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.co m

"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:OI******** ******@TK2MSFTN GP05.phx.gbl...
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

Jun 21 '06 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:Of******** ******@TK2MSFTN GP02.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?


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.
Jun 21 '06 #3

"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...

"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in
message news:Of******** ******@TK2MSFTN GP02.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?


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.


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.


btw, this is all running in VS2003 / Framework 1.1

Chris.
Jun 21 '06 #4
Chris,
What is the value of the TextBox.Accepts Return property?

ChrisM wrote:
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

Jun 21 '06 #5
FALSE, but changing it to TRUE doesn't seem to help...

Thanks anyway. If you want to have a play, see my other post in this thread
with a sample project attached...

Cheers,

Chris.
"cds_tf_1" <cd******@hotma il.com> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
Chris,
What is the value of the TextBox.Accepts Return property?

ChrisM wrote:
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

Jun 21 '06 #6
"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..

"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...

"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in
message news:Of******** ******@TK2MSFTN GP02.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?
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.


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.


btw, this is all running in VS2003 / Framework 1.1


Very weird! I've run your code and get exactly the same (inexplicable)
results.

If it's any help, I've also run it in VS2005 and Framework 2.0, and there it
behaves properly, so it looks like it's some sort of bug in the Framework
1.1. Sorry, no more time to investigate now. Good luck!

Chris Jobson
Jun 21 '06 #7
Chris,
Just for informational purposes, I don't think this group allows for
attachments. Even if it does, many people use the online Web - based version
of the reader, which definitely does not allow for same. So, you'll need to
post code samples "inline" in your message.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ChrisM" wrote:
FALSE, but changing it to TRUE doesn't seem to help...

Thanks anyway. If you want to have a play, see my other post in this thread
with a sample project attached...

Cheers,

Chris.
"cds_tf_1" <cd******@hotma il.com> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
Chris,
What is the value of the TextBox.Accepts Return property?

ChrisM wrote:
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


Jun 22 '06 #8
Peter,
Thanks for your message. I wasn't sure how many people would be able to get
at the attachment.
In order to show what I'm trying to explain however, requires a complete
mini-project containing 3 forms, too much code to sensibly include in-line
IMHO.
The best I can say is if anyone is interested in trying to help, or just
wants to see what is happening, I can email them the zip file for them to
look at. Hence my offer to email it to any interested parties.

Thanks,

Chris.

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:95******** *************** ***********@mic rosoft.com...
Chris,
Just for informational purposes, I don't think this group allows for
attachments. Even if it does, many people use the online Web - based
version
of the reader, which definitely does not allow for same. So, you'll need
to
post code samples "inline" in your message.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ChrisM" wrote:
FALSE, but changing it to TRUE doesn't seem to help...

Thanks anyway. If you want to have a play, see my other post in this
thread
with a sample project attached...

Cheers,

Chris.
"cds_tf_1" <cd******@hotma il.com> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
> Chris,
> What is the value of the TextBox.Accepts Return property?
>
> ChrisM wrote:
>> 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


Jun 22 '06 #9
Hi,
AcceptReturn only apply when the textbox is multiline
"ChrisM" <ch************ **@suedeyahoo.c om> wrote in message
news:Oq******** ******@TK2MSFTN GP04.phx.gbl...
FALSE, but changing it to TRUE doesn't seem to help...

Thanks anyway. If you want to have a play, see my other post in this
thread with a sample project attached...

Cheers,

Chris.
"cds_tf_1" <cd******@hotma il.com> wrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
Chris,
What is the value of the TextBox.Accepts Return property?

ChrisM wrote:
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


Jun 22 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1358
by: Deutsche Dogge | last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically on the popup event of the menuitem containing the container of the menuitems i wanna add (tools -> external -> {list of items dynamically added}) All the code works #1 when only the MdiParent form is used, as soon as i open an MdiChild in it, right after the popup event returns, i get this error: ...
3
1294
by: KeithO | last post by:
Using VS.Net 2003 (VB.Net) WinForm App.... Problem: I have a form (lets call it Form1) On Form1 (amongst other things) is a button (btnOne) and an text box (txtBox). .....Click on button... Shows another form (lets call it Form2)... .....All OK so far... ......Close Form2
8
1435
by: Deano | last post by:
Here's the code; Private Sub txtTeachName_LostFocus() If IsNull(Me.txtName) Then 'line A Forms!frmMainform!frmSubform.Locked = True GoTo Exit_txtName Else 'line B Forms!frmMainform!frmSubform.Locked = False 'line C
19
3609
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the thing you know ;-) After discovering that access 2000 support form properties (I'm a
2
7366
by: Zzzbla | last post by:
Hello, I'm writing a reminders project and I've been having some difficulties. It starts with a simple class that contains a timer and NotifyIcon, where the main function initializes the timer followed by Application.Run(); Whenever the timer figures out it has to do something (pop a reminder) - it creates an instance of the reminder window and calls the Show() method of that form.
1
5899
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4 code scenerio below. --------------------------------------------------------------------------- Scenerio 1
5
1400
by: Peter Oliphant | last post by:
I'm drawing graphics using the Graphics object one can grab in a Form's Paint event. But I'm getting a weird thing happening... These graphic shapes flicker (even if unchanged). UNLESS- I created a timer and had the timer update a Label on the form with timer interval set to 10. Now all the shapes I draw in the Paint event of the form draw WITHOUT flicker!!! What is updating a Label doing that is preventing flicker? Is it somehow...
10
4027
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
9
1289
by: ZorpiedoMan | last post by:
This is so weird, and I cannot even isolate the cause enough to give any clues as to how to reproduce the error, so this is probably a real shot in the dark... BUT, has anyone ever run into a situation where pressing the enter key on a textbox control is NOT captured by the KeyPress event? Now before you ask: -- The form does NOT have a default button selected.
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.