Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Creating a Picture Box

Creating a Picture Box

Scheduled Pinned Locked Moved Visual Basic
graphicsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Klazen
    wrote on last edited by
    #1

    I'm trying to write some code that creates a picture box at a certain location when a user clicks a button. I am using this statement to initialize the picturebox:

    Dim blip As Bitmap
    blip = New Bitmap(filename of bitmap goes here)
    Dim blipcase As New PictureBox
    blipcase.Image = blip

    and this statement to place the picturebox:

    Dim Theta As Double = (Point.Y * PI) / 180
    Dim location As New Point
    location.X = (225 + ((Cos(Theta) * (30 * Point.X)) - 5))
    location.Y = (225 + ((Sin(Theta) * (30 * Point.X)) - 5))
    blipcase.Location = location

    (Point is a system.drawing.point that contains the polar coordinates of the point) Now, during a break in the program, I can see that location contains the right coordinates. However, I cannot get the picturebox to appear. So I do not think it is the location part that is wrong, but the initialization that is wrong. Can anyone else see something that I might be missing?

    D 1 Reply Last reply
    0
    • K Klazen

      I'm trying to write some code that creates a picture box at a certain location when a user clicks a button. I am using this statement to initialize the picturebox:

      Dim blip As Bitmap
      blip = New Bitmap(filename of bitmap goes here)
      Dim blipcase As New PictureBox
      blipcase.Image = blip

      and this statement to place the picturebox:

      Dim Theta As Double = (Point.Y * PI) / 180
      Dim location As New Point
      location.X = (225 + ((Cos(Theta) * (30 * Point.X)) - 5))
      location.Y = (225 + ((Sin(Theta) * (30 * Point.X)) - 5))
      blipcase.Location = location

      (Point is a system.drawing.point that contains the polar coordinates of the point) Now, during a break in the program, I can see that location contains the right coordinates. However, I cannot get the picturebox to appear. So I do not think it is the location part that is wrong, but the initialization that is wrong. Can anyone else see something that I might be missing?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You didn't add the new PictureBox to your Form's Controls collection:

      Dim blipcase As New PictureBox()
      Me.Controls.Add(blipcase)

      Dave Kreskowiak Microsoft MVP - Visual Basic

      K 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You didn't add the new PictureBox to your Form's Controls collection:

        Dim blipcase As New PictureBox()
        Me.Controls.Add(blipcase)

        Dave Kreskowiak Microsoft MVP - Visual Basic

        K Offline
        K Offline
        Klazen
        wrote on last edited by
        #3

        Thank you, that worked great!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups