How can I dynamically set an avatar image in windows forms?

2

I have the following line of code that will set the client image on the screen if there is one, if it will not leave it as null. How can I make it dynamic, that is, if the client does not have the photo, will be a avatar ?

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;
}
    
asked by anonymous 28.11.2017 / 12:50

1 answer

1

Have you tried creating a default image and storing it in your project or in your database? Once created and stored, simply feed your PictureBox or your objCli.CliFoto with the default image, if objCli.CliFoto = null .

    
28.11.2017 / 15:43