我已经完成了如何将图像从 datagridview 插入图片框中的代码,但问题是,它只显示第一行的图像,这是我的代码
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                byte[] imagebyte = (byte[])dataGridView1.Rows[0].Cells["Picture"].Value;
                MemoryStream ms = new MemoryStream();
                ms.Write(imagebyte, 0, imagebyte.Length);
                Bitmap bmp = new Bitmap(ms);
                pictureBox2.Image = bmp;
            }
        }
我认为问题出在byte[] imagebyte = (byte[])dataGridView1.Rows[0].Cells["Picture"].Value;代码中,我不知道将行 [0] 替换为选定索引的代码。谢谢 :)