Click here to Skip to main content
16,017,373 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Guys

any example on how to save an image from a data bound datagidview control to memoryStream.

Thanks
dean
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-13 19:02pm    
If it's data bound, why not saving from data source instead? Besides, one thing at a time. Learn reading from DataGridView (or, better, updating a data source and using data source, not the control) separately, memory string — separately. At least, explain where do you face a problem.
—SA

1 solution

It's no different than any other implementation. The column gives you an Image object, usually a Bitmap, and you can use any of the thousands of examples all over the web.

Google for "c# convert image to byte array".
 
Share this answer
 
Comments
john belush 20-Jun-13 20:09pm    
The reason behind it, I'm trying save a datagridviewImage column to sql
john belush 20-Jun-13 20:12pm    
Yeh, I have searched the web since for days. I haven't found one example on how to save an image from an existing datagridviewImage cloumn to sql. everything is about saving an image either with filestream memorystream using opendialog
lukeer 21-Jun-13 3:05am    
Take the one with MemoryStream. There are bytes in it.
Dave Kreskowiak 21-Jun-13 8:27am    
Then you're really not understanding what the pieces of code do. You're NOT going to get a copy'n'paste solution to this. It's not that hard.

Every example starts with an Image or Bitmap (same thing really!) object, correct? You get that from your row in your data source that you bound the grid to.

Now they'll move on to setting up a MemoryStream object. Easy enough. Every implementation setups a Stream, be it a MemoryStream or FileStream, they are both Streams and work the exact same way. One just requires a filename, the other doesn't.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900