Hello,
I have the following problem (bug?):
I have one MDI form which contains one Child form. On the child form
there is one textbox. The textbox has two eventhandlers:
- MouseEnter (set the background color to red)
- MouseLeave (set the background color back to white)
The MDI form shows upon startup the Childform and contains two button
- button1: shows the ChildForm
- button2: hides the childform
The problem:
When the application starts, the child form is show and the two events
on the textbox are working perfectly:
when you move the mouse over the textbox it turns red;
when you move the mouse away from the textbox it turns white.
Clicking on the buttons of the MDI forms hides/shows the childform.
BUT after the child form was hidden and shown again, the event
MouseLeave is not execute!
when you move the mouse over the textbox it turns red;
when you move the mouse away from the textbox NOTHING happens!
Why? What do I do wrong? Is this a bug?
All suggestions, information welcome!
Robbie De Sutter
The sourcecode to repeat the problem [in VB.NET]:
Code for the MDIForm (MDI form with two buttons)
Public Class Form1
Inherits System.Windows.Forms.Form
Private theChild As child
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
theChild = New child
theChild.MdiParent = Me
theChild.Show()
End Sub
[...]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
theChild.Show()
'theChild.Visible = True '> NO SOLLUTION
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
theChild.Hide()
'theChild.Visible = False '> NO SOLLUTION
End Sub
End Class
Code for the ChildForm (normal Form with an TextBox)
Private Sub TextBox1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.MouseEnter
TextBox1.BackColor = Color.Red
End Sub
Private Sub TextBox1_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.MouseLeave
TextBox1.BackColor = Color.White
End Sub