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....
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....