Win form pops up with no reason

E

Emil

Hi,
I am using C#.
I have a form (form1) with multiple controls on it. There is a button and
when it is clicked it opens a different form (form2). When form2 is closed a
method of form1 is run and form1 becomes active. On form1 there are multiple
text fields. The problem is that when the form1 becomes active (after form2
was closed) and the focus is in a textbox and I hit the enter key, the
second form (form2) pops up without any reason.
For the text box I handle the keypress event but when this happens the event
is not captured.
I do not understand why form2 shows up without any reason.
This happens only after form2 was opened and closed.
If the form2 was not opened and I hit enter in the textboxes everything is
working fine.

Thank you.
 
H

Herfried K. Wagner [MVP]

* "Emil said:
I have a form (form1) with multiple controls on it. There is a button and
when it is clicked it opens a different form (form2). When form2 is closed a
method of form1 is run and form1 becomes active. On form1 there are multiple
text fields. The problem is that when the form1 becomes active (after form2
was closed) and the focus is in a textbox and I hit the enter key, the
second form (form2) pops up without any reason.
For the text box I handle the keypress event but when this happens the event
is not captured.

Are you sure the button is not the form's default button (assigned to
the form's 'AcceptButton' property)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top