关闭

dataGridView选中行显示图片

1021人阅读 评论(0) 收藏 举报

//选中行显示图片
        private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            using (SqlConnection sql = new SqlConnection(sqlconfig))
            {
                string temp;
                temp = this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                SqlCommand cmd = new SqlCommand("select SerialCode,ImagePath from dbo.ScannedCorrectInfo ", sql);
                sql.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (dr[0].ToString() == temp)
                    {
                        pictureBox1.Image = System.Drawing.Image.FromFile(sDr + dr[1].ToString());
                        break;
                    }
                }
              
            }
        }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:125373次
    • 积分:1565
    • 等级:
    • 排名:千里之外
    • 原创:31篇
    • 转载:7篇
    • 译文:0篇
    • 评论:11条
    文章分类
    最新评论