How to show image from URL in datagridview cell?

前端 未结 2 1447
清歌不尽
清歌不尽 2021-01-27 03:28

How do you load an image from a URL and then put it into DataGridView\'s cell (not Column header)? The rows which include the images will be added to the view at runtime based

2条回答
  •  有刺的猬
    2021-01-27 04:11

    Have a look at this SO Post https://stackoverflow.com/a/1906625/763026

     foreach (DataRow row in t.Rows)
        {
                        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(row["uri"].ToString());
                        myRequest.Method = "GET";
                        HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
                        myResponse.Close();
    
                        row["Img"] = bmp;
        }
    

提交回复
热议问题