简体   繁体   English

C# - 在 dataGridView 内部单击以获得更大的图片

[英]C# - Click inside the dataGridView for bigger picture

I have a dataGridView populated with data from an MS SQL database.我有一个 dataGridView 填充了来自 MS SQL 数据库的数据。 The data also contains images with small dimensions (140x195).数据还包含小尺寸 (140x195) 的图像。 Is there any way to click to the image and open a bigger picture?有什么办法可以点击图片打开大图吗?

Image here图片在这里

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.我找不到将图片显示到新表单而不是图片框的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM