@Ahmed Babajan , Welcome to Microsoft Q&A, I recommend that you re-add the column one by one instead of using dataGridViewProducts.DataSource = productsList;
, which may force your Image column is string type. We need to add the DataGridViewImageColumn to your current datagirdview.
Here is a code example you could refer to.
First method:
code.txt Second method: We need to change Image type in your model class:
public class Products
{
...
public Image? img { get; set; }
}
{
Products Products = new Products();
Products.Id = Convert.ToInt32(dr["Id"]);
Products.Date = dr["Date"].ToString();
Products.Customer = dr["Customer"].ToString();
Products.Product = dr["Product"].ToString();
Products.Qty = Convert.ToInt32(dr["Qty"]);
Products.Price = Convert.ToInt64(dr["Price"]);
Products.Selling = Convert.ToInt64(dr["Selling"]);
string imageurl =dr["Image"].ToString();
var request = WebRequest.Create(imageurl);
Image im = null;
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
im = Bitmap.FromStream(stream);
}
Products.img= im;
Products.Status = dr["Status"].ToString();
ProductsList.Add(Products);
}
Result:
Best Regards, Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.