0

I'm trying to set the image of a PictureBox on a FlowControl, however I can only access the background image property.

 if (File.Exists(filePath))
 {
      flowProd.Controls["picture_product"].BackgroundImage = Image.FromFile(filePath);
 }

The .Image property isn't available to me. Does anyone know of a way for me to set the Image of my picture box?

benjiiiii
  • 478
  • 10
  • 33
  • 1
    what is the FlowControl? is in WPF or windows forms? are you using any components? – Ali Yousefi Jun 19 '18 at 10:08
  • It's in Windows Forms, the FlowControl, displays a UserControl which has labels and a Picture box on. – benjiiiii Jun 19 '18 at 10:11
  • 2
    I think you need to first cast it to a `PictureBox`. `flowProd.Controls["picture_product"]` is of type Control, so it does not have an Image property. – kennyzx Jun 19 '18 at 10:13
  • Please remove the misleading flow-control tag! Also correct the wrong tilte! – TaW Jun 19 '18 at 10:16

1 Answers1

1

The Controls in FlowControl is base type of control, you have to cast control to see all of properties. exmaple:

((PictureBox)flowProd.Controls["picture_product"]).Image = Image.FromFile(filePath);
Ali Yousefi
  • 2,355
  • 2
  • 32
  • 47