Results 1 to 6 of 6

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

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    37

    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
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

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

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

  3. #3
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

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

    Double post for some reason?

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

    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
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    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 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    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
  •  



Click Here to Expand Forum to Full Width