C# 如何从datagridview获取图像url并将其放入c中的picturebox中#

C# 如何从datagridview获取图像url并将其放入c中的picturebox中#,c#,datagridview,picturebox,imageurl,C#,Datagridview,Picturebox,Imageurl,你好 我需要帮助 我想获取连接到数据库的datagridview中的图像url,并将该url添加到c#中的picturebox中 我已经搜索过了,但运气不好您可以创建图片类型的单元格并将图片放入其中。单击或输入单元格时,可以在图片框中显示。 或者,在datagrid单元格中只能有URL链接,当您单击单元格时,URL链接将用于从中获取图像 private void bt_AddPicture_Click(object sender, EventArgs e) { /

你好

我需要帮助

我想获取连接到数据库的datagridview中的图像url,并将该url添加到c#中的picturebox中


我已经搜索过了,但运气不好

您可以创建图片类型的单元格并将图片放入其中。单击或输入单元格时,可以在图片框中显示。 或者,在datagrid单元格中只能有URL链接,当您单击单元格时,URL链接将用于从中获取图像

    private void bt_AddPicture_Click(object sender, EventArgs e)
    {
        //Add image to datagrid view
        //You can add picture from SQL database instead.
        dataGridView1.Rows.Add(Image.FromFile(@"c:\Users\Programmer\Desktop\tmp\tmp\Capture.PNG"));
    }

    private void bt_ShowPicture_Click(object sender, EventArgs e)
    {
        //Show image from datagrid view in picture box.
        //You can use it in event on cellEnter
        pictureBox1.Image = ( dataGridView1.Rows[0].Cells[0].Value as Image);
        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
    }
我是对的

    private void dgData_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        picData.ImageLocation = dgData.CurrentRow.Cells[1].Value.ToString();
        picData.SizeMode = PictureBoxSizeMode.StretchImage;
    }

这非常有效

欢迎使用堆栈溢出。你的问题似乎很广泛。你至少试过什么办法来解决你的问题吗?先表现出你的努力,这样人们才能表现出他们的努力。请阅读,作为开始。。