Results 1 to 6 of 6

Thread: Add a shape to a picture box at run time

  1. #1
    New Member
    Join Date
    Apr 12
    Posts
    13

    Add a shape to a picture box at run time

    I am trying to add a circle to a picture box at run time.
    I tried the following , but I see no shape

    Dim Shape5 As Shape
    Set Shape5 = Controls.Add("vb.shape", "Myshape", Me)

    Shape5.BackStyle = 1
    Shape5.BackColor = vbRed

    The picture box is named "Pbox2"

    Thanks for your help

  2. #2
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,839

    Re: Add a shape to a picture box at run time

    Your shape is not visible
    Code:
    Shape5.Visible = True

  3. #3
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,839

    Re: Add a shape to a picture box at run time

    Double post for some reason?

  4. #4
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,431

    Re: Add a shape to a picture box at run time

    I am trying to add a circle to a picture box at run time.
    I tried the following , but I see no shape
    Try the following ! .
    Code:
    
    Dim Shape5 As Shape
    Set Shape5 = Controls.Add("vb.shape", "Myshape", Me)
    
    shap5.visible=true
    
    Shape5.BackStyle = 1
    Shape5.BackColor = vbRed

  5. #5
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,839

    Re: Add a shape to a picture box at run time

    Also if you want it inside picturebox do this

    Code:
    Set Shape5.Container = PBox2

  6. #6
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,431

    Re: Add a shape to a picture box at run time

    Yes Max187Boucher suggestion .i will also recommend .
    Code:
    Dim Shape5 As Shape
    Set Shape5 = Controls.Add("vb.shape", "Myshape", Me)
    Set Shape5.Container = PBox2
    shap5.visible=true
    
    Shape5.BackStyle = 1
    Shape5.BackColor = vbRed

Posting Permissions

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