2 Replies - 8786 Views - Last Post: 20 October 2009 - 08:28 PM Rate Topic: -----

#1 jeff87  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 17-March 09

Pull image data into picturebox from datagridview

Posted 19 October 2009 - 06:36 PM

i use these codes to pull data(string) into those textbox from datagridview.
 Dim i As Integer
	   i = DataGridView1.CurrentRow.Index

	   TextBox1.Text = DataGridView1.Item(0, i).Value
	   IDTextBox.Text = DataGridView1.Item(1, i).Value



n now i would like to add image oso,its can b saved and can be show in datagridview.
so i added this code,but i got an error (Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'.)
i noe this is the BYTE problem,but i just cant solve.......thanks in advance...


picturebox1.image = DataGridView1.Item(2, i).Value

Is This A Good Question/Topic? 0
  • +

Replies To: Pull image data into picturebox from datagridview

#2 MacAnimeGirl  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 282
  • Joined: 30-September 08

Re: Pull image data into picturebox from datagridview

Posted 20 October 2009 - 06:10 AM

Add images how? You might be able to take the value (if it's the image page) and put it into an img tag.

Can you give a little more detail?
Was This Post Helpful? 0
  • +
  • -

#3 jeff87  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 17-March 09

Re: Pull image data into picturebox from datagridview

Posted 20 October 2009 - 08:28 PM


		Dim fs As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
		Dim s As String = TextBox1.Text
		'Read the output in binary reader
		Dim r As BinaryReader = New BinaryReader(fs)
		'Declare a byte array to save the content of the file to be saved
		Dim FileByteArray(fs.Length - 1) As Byte
		r.Read(FileByteArray, 0, CInt(fs.Length))

  addcomm.Parameters.Add("@Photo", System.Data.OleDb.OleDbType.Binary).Value = FileByteArray


i used code above 2 add!...n it will show in the datagridview.....
and when i click on the datagridview,it will load to a picturebox!thx for reply!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1