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. Using picture boxes?

Using picture boxes?

Scheduled Pinned Locked Moved Visual Basic
questionhelplearning
6 Posts 3 Posters 1 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.
  • T Offline
    T Offline
    Toola
    wrote on last edited by
    #1

    Hi everyone.. I just have a few small Q's about using picture boxes, and need your help :confused: 1-How can i make the picture inside the box strechable,i.e. takes the size of the box? 2-How can i create a new picture box from inside the program (code)?and add a pic to it? I bet you already guessed..well ya, i'm a beginner ;P Plz help me anyone ...i,m in a hurry :sigh: Toola "If you can't beat your computer at chess, do what I did — try kick-boxing." — Matt Larson.

    N 1 Reply Last reply
    0
    • T Toola

      Hi everyone.. I just have a few small Q's about using picture boxes, and need your help :confused: 1-How can i make the picture inside the box strechable,i.e. takes the size of the box? 2-How can i create a new picture box from inside the program (code)?and add a pic to it? I bet you already guessed..well ya, i'm a beginner ;P Plz help me anyone ...i,m in a hurry :sigh: Toola "If you can't beat your computer at chess, do what I did — try kick-boxing." — Matt Larson.

      N Offline
      N Offline
      Nadroj
      wrote on last edited by
      #2

      1- there is a property for the PictureBox object called SizeMode. set this to StretchImage in order for the image to take the size of the pictureboxes' dimensions (itll stretch/shrink the image to the boxes' dimensions). ex: PictureBox1.SizeMode = StrechImage in code, or simply set the objects property at design time (in properties window, of course) 2- to set the picture to be displayed in the picturebox, use its Image property. ex: PictureBox1.Image = Image.FromFile("C:\my Pictures\pic1.bmp"). note: you can only use certain formats or u will get an error. i dont remember the full list but its most of the main ones (.bmp, either .jpg or .jpeg [i thought only 1 of the 2 worked], .gif, etc). i dont know how to programmatically create another picturebox at run time. hopefully sum1 can post info on it. ------------------------ Jordan. III

      T 1 Reply Last reply
      0
      • N Nadroj

        1- there is a property for the PictureBox object called SizeMode. set this to StretchImage in order for the image to take the size of the pictureboxes' dimensions (itll stretch/shrink the image to the boxes' dimensions). ex: PictureBox1.SizeMode = StrechImage in code, or simply set the objects property at design time (in properties window, of course) 2- to set the picture to be displayed in the picturebox, use its Image property. ex: PictureBox1.Image = Image.FromFile("C:\my Pictures\pic1.bmp"). note: you can only use certain formats or u will get an error. i dont remember the full list but its most of the main ones (.bmp, either .jpg or .jpeg [i thought only 1 of the 2 worked], .gif, etc). i dont know how to programmatically create another picturebox at run time. hopefully sum1 can post info on it. ------------------------ Jordan. III

        T Offline
        T Offline
        Toola
        wrote on last edited by
        #3

        Thaaaaanx alooot Nadroj, you made my day :-D just one answer left i hope someone can answer it!! Btw, i saw a function called CreateControl , but i really don't know what it does or what parameters it takes? i tried using it, but i failed , i keep giving it the wrong parameters! do you know how to use it? Toola "If you can't beat your computer at chess, do what I did — try kick-boxing." — Matt Larson.

        N N 2 Replies Last reply
        0
        • T Toola

          Thaaaaanx alooot Nadroj, you made my day :-D just one answer left i hope someone can answer it!! Btw, i saw a function called CreateControl , but i really don't know what it does or what parameters it takes? i tried using it, but i failed , i keep giving it the wrong parameters! do you know how to use it? Toola "If you can't beat your computer at chess, do what I did — try kick-boxing." — Matt Larson.

          N Offline
          N Offline
          Nadroj
          wrote on last edited by
          #4

          no sorry i have never looked into creating objects at runtime, so i wouldnt know where to start. hopefully sum1 can post a how-to, and inform the both of us! ------------------------ Jordan. III

          1 Reply Last reply
          0
          • T Toola

            Thaaaaanx alooot Nadroj, you made my day :-D just one answer left i hope someone can answer it!! Btw, i saw a function called CreateControl , but i really don't know what it does or what parameters it takes? i tried using it, but i failed , i keep giving it the wrong parameters! do you know how to use it? Toola "If you can't beat your computer at chess, do what I did — try kick-boxing." — Matt Larson.

            N Offline
            N Offline
            Nick Parker
            wrote on last edited by
            #5

            Toola wrote: Btw, i saw a function called CreateControl , but i really don't know what it does or what parameters it takes? i tried using it, but i failed , i keep giving it the wrong parameters! do you know how to use it? MSDN[^] is a great source of information. You will find that the PictureBox class that you are using inherits from System.Windows.Forms.Control, which contains a method called CreateControl(). Read more here[^] if you are interested. - Nick Parker
            My Blog | My Articles

            T 1 Reply Last reply
            0
            • N Nick Parker

              Toola wrote: Btw, i saw a function called CreateControl , but i really don't know what it does or what parameters it takes? i tried using it, but i failed , i keep giving it the wrong parameters! do you know how to use it? MSDN[^] is a great source of information. You will find that the PictureBox class that you are using inherits from System.Windows.Forms.Control, which contains a method called CreateControl(). Read more here[^] if you are interested. - Nick Parker
              My Blog | My Articles

              T Offline
              T Offline
              Toola
              wrote on last edited by
              #6

              Thanx alot Nick. I checked out MSDN's site & found it very useful, sure bet i'll be entering that site again!! I already found a way to create a PictureBox at run time without using the CreateControl() method, Simply as this: Dim pb As New PictureBox System.Windows.Forms.Form1.Controls.Add(pb) (or Me.Controls.Add(pb)) --------------------------- Toola "The SMALL details are what make the difference in the BIG picture"

              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