点击dgv某列的单元格时触发事件的方法
阅读原文时间:2023年07月09日阅读:1

private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1) //第一列是 ID (隐藏),第二列才是图片(Pic)列
{
int rowIndex = this.dataGridView1.CurrentRow.Index; // 取得当前单元格的行Index
string pic = dataGridView1.Rows[rowIndex].Cells["Pic"].Value.ToString();
byte[] str = Convert.FromBase64String(pic);

Image image = GetImage(str);
this.pictureBox1.Image = image;
}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章