Using picture boxes?
-
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.
-
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.
1- there is a property for the PictureBox object called
SizeMode
. set this toStretchImage
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 itsImage
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 -
1- there is a property for the PictureBox object called
SizeMode
. set this toStretchImage
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 itsImage
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. IIIThaaaaanx 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.
-
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.
-
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.
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 fromSystem.Windows.Forms.Control
, which contains a method calledCreateControl()
. Read more here[^] if you are interested. - Nick Parker
My Blog | My Articles -
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 fromSystem.Windows.Forms.Control
, which contains a method calledCreateControl()
. Read more here[^] if you are interested. - Nick Parker
My Blog | My ArticlesThanx 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"