简体   繁体   中英

How to read picture path with datagridview c#

i wanna ask you something , that i have a data grid that show specific data from my database . this data include a picture box that must show the picture from picture's path that stored in database.The picture path is stored as a string value in column pic in database.But data grid show the all data without showing any picture in the picture box. I want it when i click on data gird cell show me the picture of that row in picture box (reading the picture path from database and show the picture in the picture box) this is my code :

private void searchInfo()
{
    con.Open();
    adapter = new OleDbDataAdapter("select * from customers where c_name like'%" + c_name_search.Text + "%'", con);
    adapter.Fill(table);

    res_cid.DataBindings.Add("text", table, "id");
    res_cname.DataBindings.Add("text", table, "c_name");
    pcard_type_res.DataBindings.Add("text", table, "c_pic_type");
    picturebox1.DataBindings.Add("text",table,"pic");
    picturebox1.SizeMode = PictureBoxSizeMode.StretchImage;
    bmb = this.BindingContext[table];
    datagrid.DataSource = table;
     con.Close();
}

thank you ...

Maybe if you change the "text" parameter to "Image" or "ImageLocation".

For example:

picturebox1.DataBindings.Add(new Binding("ImageLocation",table,"yourtablename.yourcolumnname",true));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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