AcceptButton and Key-Events

F

Frank Lakmann

Hello,
I have a problem with Key-Events on Forms in connection with hitting
the AcceptButton.
Situation:
- MdiChildForm 1 with DataGrid for selecting records. This DataGrid
has AllowNavigation false, ReadOnly true and all the textBoxes of all
the DataGridTextColumns are disabled, too.
The KeyUp-Event of this DataGrid is bound to a method that opens a
second form for editing that selected record when the Enter-key
(KeyValue 13) is used.
- EditForm 2 has Button btnOK for saving the data and closing the
form. The MdiParent of this form is the same as 1's. The AcceptButton
property is set to btnOK.

Hitting Enter in form 2 closes it (ok, that's what I want) and the
next thing happening is the KeyUp-Event in form 1 and hello ... here
is form 2 again (what is absolutely not wanted). There are neither
KeyDown, KeyPress or KeyUp occuring on form 2 before it closes and no
KeyDown or KeyPress on form 1.

How can I get a useful behaviour? Any hints are appreciated.
 

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