I have a dataGridView populated with data from an MS SQL database. The data also contains images with small dimensions (140x195). Is there any way to click to the image and open a bigger picture?
I am using the following code to show the picture to the pictureBox.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.CurrentRow.Selected = true;
int cardNo = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Number"].FormattedValue);
con.Open();
SqlCommand cmd = new SqlCommand("SELECT ImageFull FROM SS4 WHERE CardNo = '" + cardNo+"'", con);
string img = cmd.ExecuteScalar().ToString();
pbCard.Image = Image.FromFile(img);
con.Close();
}
The path for the image is saved to the database. I cannot find a way to show the picture to a new form instead to a pictureBox.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.