There is a dataGridView in which the database is displayed. I want a double click on a cell to open an image that is stored as a link in a cell. I have the code:
private void dataGridView1_DoubleClick(object sender, EventArgs e) { var link = dataGridView1.SelectedCells; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Image = Image.FromFile(link); } An error occurs: Error 2 Argument "1": type conversion from "System.Windows.Forms.DataGridViewSelectedCellCollection" to "string" is impossible
Tell me how to write the code correctly.
I tried another version:
string p = Convert.ToString(dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Image = Image.FromFile(p); Also does not work.
dataGridView1.SelectedCellsclass instances are in thedataGridView1.SelectedCellscollection? What fields are there? - tym32167