voila mon code
public void pic_Format(object sender, ConvertEventArgs e)
{
Bitmap bmp = null;
byte[] img = (byte[])e.Value;
using (MemoryStream ms = new MemoryStream())
{
ms.Write(img, 0, img.Length);
ms.GetBuffer();
bmp= new Bitmap(ms);
}
if (bmp != null)
{
e.Value = bmp;
}
}
//
ici ou j'ai appelé ma procedure
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1)
{
MessageBox.Show("veuillez selectionné les cases pour avoir les données sur vos zone de texte");
}
else
{
id = Convert.ToInt16(dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString());
dbpf = DbProviderFactories.GetFactory("System.Data.SqlClient");
cn = dbpf.CreateConnection();
cn.ConnectionString = "server=(local);database=TRANSPORT;integrated security=true";
cn.Open();
da = dbpf.CreateDataAdapter();
da.SelectCommand = cn.CreateCommand();
da.SelectCommand.CommandText = "select * from view_2 where id='" + id + "'";
ds = new DataSet();
da.Fill(ds, "mag");
dt2 = ds.Tables["mag"];
pictureBox1.DataBindings.Clear();
foreach (DataRow dr in dt2.Rows)
{
txt_matr.Text = dr["matricule"].ToString();
textBox1.Text = dr["id"].ToString();
txtNom.Text = dr["nom"].ToString();
txtprenom.Text = dr["prenom_personnel"].ToString();
txtstatut.Text = dr["statut"].ToString();
txtplainte.Text = dr["plainte"].ToString();
combshift.Text = dr["nom_shift"].ToString();
cbxbus.Text = dr["nom_chauffeur"].ToString();
cbxdepa.Text = dr["nom_dep"].ToString();
cbxchef.Text = dr["nom_chef"].ToString();
cbx_station.Text = dr["nom_station"].ToString();
Binding b = new Binding("Image", ds.Tables["mag"], "photos", true);
b.Format += new ConvertEventHandler(pic_Format);
pictureBox1.DataBindings.Add(b);
break;
}
}
EDIT : AJOUT DES BALISES DE CODE !
Merci d'y penser la prochaine fois.
(jordane)