C#怎么把数据库里的图片路径加载到图片里??
privatevoiddataGridView1_CellClick(objectsender,DataGridViewCellEventArgse){inti=e.Ro...
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int i = e.RowIndex;
if (i < 0) return;
txt__id.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
txt_xm.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
com_dtt.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
string sex = dataGridView1.Rows[i].Cells[3].Value.ToString();
if (sex == "男") rbt_man.Checked = true;
else rbt_women.Checked = true;
string mg = dataGridView1.Rows[i].Cells[4].Value.ToString();
if (mg == "已婚") rbt_yh.Checked = true;
else rbt_wh.Checked = true;
dateTimePicker1.Value = Convert.ToDateTime(dataGridView1.Rows[i].Cells[5].Value.ToString());
txt_adr.Text = dataGridView1.Rows[i].Cells[6].Value.ToString();
txt_tel.Text = dataGridView1.Rows[i].Cells[7].Value.ToString();
txt_datacard.Text = dataGridView1.Rows[i].Cells[8].Value.ToString();
txt_cpy.Text = dataGridView1.Rows[i].Cells[9].Value.ToString();
pictureBox1.Image = Image.FromFile(dataGridView1.Rows[i].Cells[10].Value.ToString());//这句错了,请大神们改改
} 展开
{
int i = e.RowIndex;
if (i < 0) return;
txt__id.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
txt_xm.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
com_dtt.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
string sex = dataGridView1.Rows[i].Cells[3].Value.ToString();
if (sex == "男") rbt_man.Checked = true;
else rbt_women.Checked = true;
string mg = dataGridView1.Rows[i].Cells[4].Value.ToString();
if (mg == "已婚") rbt_yh.Checked = true;
else rbt_wh.Checked = true;
dateTimePicker1.Value = Convert.ToDateTime(dataGridView1.Rows[i].Cells[5].Value.ToString());
txt_adr.Text = dataGridView1.Rows[i].Cells[6].Value.ToString();
txt_tel.Text = dataGridView1.Rows[i].Cells[7].Value.ToString();
txt_datacard.Text = dataGridView1.Rows[i].Cells[8].Value.ToString();
txt_cpy.Text = dataGridView1.Rows[i].Cells[9].Value.ToString();
pictureBox1.Image = Image.FromFile(dataGridView1.Rows[i].Cells[10].Value.ToString());//这句错了,请大神们改改
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询