change event when mouse is clicked outside a panel
Hi i am trying to work out the event that handles when i click outside a area "i guess that is how to put it"
This is exactly what i mean
I have a panel i.e
and a text box i.e
Code:
Profile_NameTextBox
I whish for the ProfileNamePanel to change color when i click inside the Profile_NameTextBox which i obviously done using
Code:
Private Sub Profile_NameTextBox_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Profile_NameTextBox.MouseClick
ProfileNamePanel.BackColor = Color.Aquamarine
End Sub
BUT now i am stuck trying to work out what event handles changing the color again say to black once i have clicked away from
Profile_NameTextBox
So in short i whish to change a panels color when i click on a textbox then after i finish that textbox and click elsewhere i want to change the color of the panel again.
Cheers in advance
Re: change event when mouse is clicked outside a panel
the form, textbox, + panel all have a _MouseClick event of their own.
also you can use 1 event to handle multiple control's events:
Code:
Private Sub multiple_controls__MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick, Me.MouseClick
End Sub
Re: change event when mouse is clicked outside a panel
The best place to put your code is the GotFocus and LostFocus events of Profile_NameTextBox, by this way you don't have to put the code in the MouseClick event of all other controls.
Code:
Private Sub Profile_NameTextBox_GotFocus(sender As Object, e As EventArgs) Handles Profile_NameTextBox.GotFocus
ProfileNamePanel.BackColor = Color.Aquamarine
End Sub
Private Sub Profile_NameTextBox_LostFocus(sender As Object, e As EventArgs) Handles Profile_NameTextBox.LostFocus
ProfileNamePanel.BackColor = Color.Black
End Sub
Re: change event when mouse is clicked outside a panel
Thanks guys very helpfull ;)