Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

C#: Is it possible to access a component's property via the component name in a string?

I think, this question is a bit weird.

But I'll try to explain, what I need:

Assume, I have a string with the value "Form" and an integer with the value 1. Is there a way to put these values together (=> 'Form1') and access the properties of Form1 then (similar to getElementById in Javascript)?

For example:

"Form"+1 => Form1

=> Form1.BackgroundColor = Colors.Red;

I hope you got the basic idea of what I'm going to try and I hope you can tell me how I can realise this (if even possible).

Update:

Well, the form was just an example. The object I want to get by name is a SDL.NET sprite. Thanks anyway. I'll try this.

3 Antworten

Relevanz
  • vor 1 Jahrzehnt
    Beste Antwort

    Using Reflection you can access the properties of an object by name, but not an arbitrary object like this. What you can do is used The OpenForms property of the Application object to retrieve a list of open forms. You can iterate through that looking for the name of the form.

  • clauss
    Lv 4
    vor 4 Jahren

    Now you have defined the situation we are able to help. you could desire to verify if the shutter is easy sensitized for vehicle exposure. despite if this is mechanical, the postpone of the image resistor, could be so great as to spark off the sunshine booster after the shutter has closed. this is greater efficient if feasible, to faucet into the availability to the interior flash, and repeat this ability via a transistor on the distant flash.

  • Anonym
    vor 1 Jahrzehnt

    MSDN is better place to ask question like this.

    After opening below link see left panel.

    BEST REGARD

Haben Sie noch Fragen? Jetzt beantworten lassen.