Win form pops up with no reason

  • Thread starter Thread starter Emil
  • Start date Start date
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.
 
* "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)?
 
Back
Top