1
I’m 6 PictureBox, then, when saving the photo in the database, save together in which PictureBox she was.
So when uploading the photos in a view, I need each photo to be displayed in its respective PictureBox, perform the query in the database assigning the values to the List called VetorImagem.
Return one array of byte and the name of PictureBox where the photo was.
Then to mount the photo and display on PictureBox, I use the code below:`
//Crio o List chamado VetorImagem.
List<Classes.Dictionary.Crm.List_Photo_Crm> vetorImagem = new List<Classes.Dictionary.Crm.List_Photo_Crm>();
//Instancio minha classe de consulto ao banco de dados.
Classes.Dictionary.Crm.Analise_Crm Dic_foto = new Classes.Dictionary.Crm.Analise_Crm();
//realizo a consulta e associo ao List VetorImagem
vetorImagem = Dic_foto.preenche_fotos(textEdit8.Text);`
for(int a = 0; a < vetorImagem.Count; a++)
{
//defini um nome de arquivo
string strNomeArquivo = Convert.ToString(DateTime.Now.ToFileTime());
using (MemoryStream stream = new MemoryStream())
{
stream.Write(vetorImagem[a].photo, 0, vetorImagem[a].photo.Length);
stream.Flush();
vetorImagem[a].PictureBox_Name.Image = Image.FromStream(stream);
vetorImagem[a].PictureBox_Name.SizeMode = PictureBoxSizeMode.StretchImage;
stream.Close();
}
}
However, how do I locate the PictureBox?
Yeah, when using vetorImagem[a].PictureBox_Name I only have the name of the object.
you already have the 6 picturebox on the screen, or will put them at runtime ?
– Rovann Linhalis
@Rovannlinhalis they already exist, I just need to "call them"
– Thomas Erich Pimentel
actually you don’t have to instantiate them, just locate the already existing instance in the form (is winforms correct?), see the answer I put up
– Rovann Linhalis
Correct, perfect. Thank you
– Thomas Erich Pimentel