0

I'd like to make a game where you can press some random generated pictures and I have the name of the picture in a string variable. How can I access the name to change the pictures visibility, or is there another way?

What is mean is this: VarWithPicturesName.Visible = false;

Wim Ombelets
  • 5,097
  • 3
  • 39
  • 55
  • Possible duplicate of [Set property value using property name](https://stackoverflow.com/questions/9404523/set-property-value-using-property-name) – Sinatr Aug 05 '19 at 11:16
  • 1
    It's possible to access that `PictureBox` using [Controls](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.controls) property (usually by knowing parent container or with recursion) and using `Tag` to hold custom data. Or you can simply have `Dictionary` to map string name to real instance, when creating new control - add it to dictionary. – Sinatr Aug 05 '19 at 11:19
  • @Sinatr thank you very much I was able to solve the problem with the Dictionary solution. – Kerner Máté Aug 05 '19 at 13:38

0 Answers0