Hi, I'm having some problems with picturebox events in VB.net.
I've 2 forms
Main form (Form1) :
1 button
Second form(Form2) :
1 picturebox
Main form code
Dim TESTForm As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TESTForm.ShowDialog(Me)
End Sub
Second form code
Friend Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = New Bitmap("C:\Documents and Settings\kevin\Desktop\Cuttool\01ok_small_h.png")
End Sub
Friend Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = New Bitmap("C:\Documents and Settings\kevin\Desktop\Cuttool\01ok_small_n.png")
End Sub
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Me.Hide()
End Sub
The problem :
the code works fine the first time where my picture box will change image each time my mouse hover in and out.
But after i clicked on the picturebox to hide the form(Form2) and reload it by clicking on the button on Form1, I kindda lost my mouseEnter and mouseLeave events for the picturebox. Funny thing is i can still get my click event for the picturebox.
Is this a bug or am i doing something wrong here?
Thanks in advance
I've 2 forms
Main form (Form1) :
1 button
Second form(Form2) :
1 picturebox
Main form code
Dim TESTForm As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TESTForm.ShowDialog(Me)
End Sub
Second form code
Friend Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = New Bitmap("C:\Documents and Settings\kevin\Desktop\Cuttool\01ok_small_h.png")
End Sub
Friend Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = New Bitmap("C:\Documents and Settings\kevin\Desktop\Cuttool\01ok_small_n.png")
End Sub
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Me.Hide()
End Sub
The problem :
the code works fine the first time where my picture box will change image each time my mouse hover in and out.
But after i clicked on the picturebox to hide the form(Form2) and reload it by clicking on the button on Form1, I kindda lost my mouseEnter and mouseLeave events for the picturebox. Funny thing is i can still get my click event for the picturebox.
Is this a bug or am i doing something wrong here?
Thanks in advance