6 Replies - 11958 Views - Last Post: 16 September 2007 - 01:50 AM Rate Topic: -----

#1 enteng  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 02-September 07

how to insert picture when its in run mode?

Post icon  Posted 05 September 2007 - 09:39 PM

i have a form with different fields, one of those is image type. my question is how can i insert picture when my form is in the run mode?

how can i get picture from my folder and place it into image control.

thank you very much
Is This A Good Question/Topic? 1

Replies To: how to insert picture when its in run mode?

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,085
  • Joined: 18-April 07

Re: how to insert picture when its in run mode?

Posted 05 September 2007 - 10:32 PM

You just have to use the Load() method of the picturebox control. It takes a path to the actual image.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		' Load picture of that stallion coder Martyr2
		picturebox1.Load("c:\\Martyr2.jpg")
End Sub



That is all there is to it. Now you could use a file open dialog to allow the user to select the image. This is a basic implementation example of it and should really include error checking and such, plus making sure the file selected is an image.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		' Open the file dialog and check if they selected "OK"
		' If they did, take the filename and load it into the picturebox.
		If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
				picturebox1.Load(OpenFileDialog1.FileName)
		End If
End Sub



Hope this makes some sense and helps you out.

This post has been edited by Martyr2: 05 September 2007 - 10:34 PM

Was This Post Helpful? 0
  • +
  • -

#3 enteng  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 02-September 07

Re: how to insert picture when its in run mode?

Posted 12 September 2007 - 07:58 PM

thank you for the code, my main concern is how to save it to my present table? and bu using that code, i only see .bmp files i want also to see the .jpg or .jpeg format.

thanks
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to insert picture when its in run mode?

Posted 12 September 2007 - 08:38 PM

View Postenteng, on 12 Sep, 2007 - 07:58 PM, said:

thank you for the code, my main concern is how to save it to my present table? and bu using that code, i only see .bmp files i want also to see the .jpg or .jpeg format.

thanks


Explain what you mean by my main concern is how to save it to my present table? Are you going to be saving the image to the database, what do you mean?
Was This Post Helpful? 0
  • +
  • -

#5 enteng  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 02-September 07

Re: how to insert picture when its in run mode?

Posted 12 September 2007 - 08:47 PM

yes, im going to save the image to the database/table.

i have a form in run mode that can add/edit data into my table. by adding or editing a field in my form i can save my data to my table. with the code given by Martyr2 i can browse my folder to display image in my form (only in form) so when i navigate to other records the displayed image is display again to other records. when i exit my apps and run again my picturebox is empty, my previous insert of image is not displayed as weel as no picture in my picture field.
Was This Post Helpful? 0
  • +
  • -

#6 dragonjewel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 60
  • Joined: 06-September 07

Re: how to insert picture when its in run mode?

Posted 13 September 2007 - 02:21 PM

You might consider an image list and then create a relational table of the image names and their index number. Then you are storing the index number in your table.

If there is a good wy to make a table of images I am game. But this is one way I incorporated a similiar function into my VB program.
Was This Post Helpful? 0
  • +
  • -

#7 enteng  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 56
  • Joined: 02-September 07

Re: how to insert picture when its in run mode?

Posted 16 September 2007 - 01:50 AM

thank you for all your helo, my problem in inserting and saving to the table is now solve. but i still 2 more problem: login form and searching/modifying in two tables. again many thanks for your help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1