CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    95

    UserControl and PictureBox

    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.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: UserControl and PictureBox

    > 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.


  3. #3
    Join Date
    May 2001
    Location
    India
    Posts
    25

    Re: UserControl and PictureBox

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured