MDI and .NET 1.1 bug

B

Bruno Rino

I have stumbled upon a weird behavior of .NET 1.1 when dealing with MDI
forms (but .NET 1.0 worked fine).

I'd really like to know if anybody solved this one...
The bug is hard to explain, so I'll go slowly:

A small application can reproduce the bug:
1. The application loads the MDI form.
2. This form loads an MDI child form.
3. The child form has a textbox and a button.
4. When clicked, the button loads another MDI child form.

The bug:
1. I click the button, so a new form is loaded. So far so good.
2. I close the form
3. I click on the textbox (so it has the focus)
4. I press the Enter key.
5. The bug happens: the code for the button click event handler is launched.

code snippet for the MDI form (IsMdiContainer property set to True):
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim form As New Form1
form.MdiParent = Me
form.Show()
End Sub


code snippet for the MDI child form (I used the same class for both forms)
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim m1 As Form1 = New Form1
m1.MdiParent = Me.MdiParent
m1.Show()
End Sub



PS: Is there any rule on the newsgroup about not making attachments? Because
I could attach the source and project files, but I don't want to break any
rules....
 
G

Girish NS

Hi,

There are 2 properties in the form - AcceptButton and CancelButton. If
button control is assigned to AcceptButton property, its event handler is
fired when u press enter key anywhere in the form. (even inside a textbox).
So just check the AcceptButton property to see whether its assigned with the
button control.

Hope this helps...

Girish.
 

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