I have a Picturebox and TextBox on a usercontrol. I want to draw a border around the the usercontrol when the usercontrol (or anything else in it) is selected. I have a sub that draws the border around the control. The sub is called from the Enter event of the UserControl and the TextControl. However, when I try to do the same thing with the PictureBox, I don't see an Enter event listed for the PictureBox (strange as it is inherited from control) and while the GetFocus event is available, it does not seem to fire. Do I have to enable the focus events in the PictureBox somehow The PictureBox is already set to both Visible and Enabled = True.
Any suggestions Is their an easier way to draw a border around a user control when it is selected that I am missing
I'm using VB2003, Framework 1.1
Thanks

PictureBox GotFocus/Enter events
Beav1810
Kees van der Oord
Private Sub PictureBox1_Mousedown(...) handles PictureBox1.MouseDown
Me.PictureBox1.Select
End Sub
I don't know if this would have solved the problem without making the other change suggested above, since I didn't go back after making the suggested modification.
Mario02
I had a look using Reflector, and if control sees a mouse down and the control is selectable (indicated by ControlStyles.Selectable) then focus is moved to it. So I'm not sure what is happening.
Also one thing I forget: you want to also set TabStop to true in the constructor so this will allow you to press TAB to move to it.
_ _
What you need to do is create a new class and derive from the PictureBox control. In its constructor do the following:
Public Sub New()
SetStyle(ControlStyles.Selectable, True);
End
This will indicate to the framework that it can get focus and therefore the focus events (Enter, Leave, GotFocus and LostFocus) will be raised.