how to display image from gridview on picturebox
-
Hi guys I'm not able to display image from tablegridview to picturebox visual basic 2010 studio. I know how to reference text value from a cell on tablegridview to textbox I had been created . this the Code how to do this :
TextBox2.Text = Table1DataGridView.Rows(0).Cells(3).Value.ToString
my question is how to do it with image if you have this image on Table1DataGridView I tried this code for image but it doesn't work I got error
PictureBox1.image=Table1DataGridView.Rows(0).Cells(2).Value.Toimage
or
PictureBox1.image=Table1DataGridView.Rows(0).Cells(2).Value
both of these cod not work and I get error please Help I hope that some one can solve this complex problem and i will be great full for you . mju10ht@gmail.com
-
Hi guys I'm not able to display image from tablegridview to picturebox visual basic 2010 studio. I know how to reference text value from a cell on tablegridview to textbox I had been created . this the Code how to do this :
TextBox2.Text = Table1DataGridView.Rows(0).Cells(3).Value.ToString
my question is how to do it with image if you have this image on Table1DataGridView I tried this code for image but it doesn't work I got error
PictureBox1.image=Table1DataGridView.Rows(0).Cells(2).Value.Toimage
or
PictureBox1.image=Table1DataGridView.Rows(0).Cells(2).Value
both of these cod not work and I get error please Help I hope that some one can solve this complex problem and i will be great full for you . mju10ht@gmail.com
-
Try something like this;
PictureBox1.image = CType(Table1DataGridView.Rows(0).Cells(2).Value, Bitmap)
Bastard Programmer from Hell :suss:
thank you for help, but I still get error show me this : Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Bitmap'. I wonder if that code work to you, so that means the code will be correct and I did something wrong :confused: please I need help
-
thank you for help, but I still get error show me this : Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Bitmap'. I wonder if that code work to you, so that means the code will be correct and I did something wrong :confused: please I need help
-
Dim bytes as Byte() = ' Your value from the grid goes here
Using ms as new MemoryStream(bytes)
Dim img As Bitmap = CType(Image.FromStream(ms), Bitmap)
PictureBox1.Image = img
End UsingBastard Programmer from Hell :suss:
I don't why he put blue line under MemoryStream(bytes)
Dim bytes As Byte() = Table5DataGridView.Rows(0).Cells(3).Value
Using ms As New MemoryStream(bytes)
Dim img As Bitmap = CType(Image.FromStream(ms), Bitmap)
PictureBox1.Image = img
End Usingon error list show me MemoryStream(bytes)is not defined :(
-
I don't why he put blue line under MemoryStream(bytes)
Dim bytes As Byte() = Table5DataGridView.Rows(0).Cells(3).Value
Using ms As New MemoryStream(bytes)
Dim img As Bitmap = CType(Image.FromStream(ms), Bitmap)
PictureBox1.Image = img
End Usingon error list show me MemoryStream(bytes)is not defined :(
-
Prefix it with the correct namespace, like this;
Using ms As New System.IO.MemoryStream(bytes)
..or Import the namespace :)
Bastard Programmer from Hell :suss:
:-D finally yes it's work how can I say thank you for your help .. but you know what you are my super hero who save my time after two days of stupid attempts went fail. oh my God why I didn't ask you from the first day i got this problem, I have a project and this project depends on this code otherwise I will stop work on this project after I faced this problem but now I'm very excited to back work on my project :rose::rose::rose: :rolleyes:
-
:-D finally yes it's work how can I say thank you for your help .. but you know what you are my super hero who save my time after two days of stupid attempts went fail. oh my God why I didn't ask you from the first day i got this problem, I have a project and this project depends on this code otherwise I will stop work on this project after I faced this problem but now I'm very excited to back work on my project :rose::rose::rose: :rolleyes:
-
Nicely done
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012