How can I dynamically set an avatar photo in windows Forms?

Asked

Viewed 47 times

2

I have the following line of code that will set the client image on the screen if there is, if not will leave as null. How can I leave dynamic, IE, if the customer does not have the photo will set an image avatar ?

Avatar][1]

if (!string.IsNullOrEmpty(objCli.CliFoto) == true){
         byte[] bytes = Convert.FromBase64String(objCli.CliFoto.Replace("data:image;base64,", ""));
      using(MemoryStream ms = new MemoryStream(bytes)){
         picbImagemCli.Image = Image.FromStream(ms);
      }
} else {
   picbImagemCli.Image = null;
}
  • Changing picbImagemCli.Image = null;` on your Else to the default image does not resolve?

1 answer

1


Have you tried creating a standard (default) image and storing it in your project or database? Once created and stored, just feed your Picturebox or your objCli.Clifoto with the default image, if the objCli.Clifoto= null.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.