Click to See Complete Forum and Search --> : UserControl and PictureBox


slcotten
May 26th, 2001, 12:30 PM
I have never created a UserControl before and am working on my first one now. So I have two issues that I need help with. First, when you create a new UserControl, there are the intrisic properties that come along with it. How can I add to those properties so that when I call it from the UserControl's container form I can do it like this:
UserControl1.MyProperty = MyValue
???

Secondly, I am having trouble using pictureboxes on the UserContorl. Maybe I would have the same trouble if I used them in this way on a regurlar form too... I don't know. But anyway, this is what I am doing. I have two pictureboxes (picCon and picX). picX is a child of picCon. picX has four lines in it. When mouse moves over picX I want these lines to show... but when mouse moves over picCon I want these lines to be invisible. So this is the code that I have:

Private Sub picX_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lin1.Visible = True
lin2.Visible = True
lin3.Visible = True
lin4.Visible = True
End Sub

Private Sub picCon_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lin1.Visible = False
lin2.Visible = False
lin3.Visible = False
lin4.Visible = False
End Sub

Both events fire properly. I move my mouse cursor over picX and the lines show. However when I move my cursor out of picX and over picCon the lines still are visible. I set a breakpoint on Sub picCon_MouseMove and it breaks and executes the code properly and the lines disappear. With no breakpoint the lines will not disappear and they will not become invisible until I move my mouse cursor out of the UserControl and onto other areas of my container form. This leads me to believe that there is something I must change with the way the UserControl or the pictureboxes repaint, but I do not know what or how I should do it.

If you could help on this, I would greatly appreciate it... and thanks in advance.

shree
May 26th, 2001, 12:47 PM
> I set a breakpoint on Sub picCon_MouseMove and it breaks and executes the code properly and the lines disappear

If I see something happening with breakpoints and not during normal run, the first thing I do is place a DoEvents instead of the breakpoint.

sameer developer
May 28th, 2001, 12:27 AM
If something is visible through break point and not in run mode then u will need to repaint the user control.
You can use the Paint method to refresh your user control.