C# – Click inside the dataGridView for 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.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top