Announcement

Collapse
No announcement yet.

Control Property dynamisch

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Control Property dynamisch

    Hallo
    Aus einer liste habe ich den Namen einer Control (z.B. txtName), den Property-Name (z.B. Visible) und den Property-Wert (z.B.TRUE)

    Wie ich den Control finde ist mir klar, aber wie kann ich den Property-Wert zuweisen?

    Code:
    Dim contrName As String = "txtName"
                Dim propName As String = "Visible"
                Dim propValue As Boolean = True
                Dim mycontrol As Control
    
                mycontrol = Me.Controls.Find(contrName, True)(0)
                mycontrol.properties.item(propName) = propValue            ' Das ist leider wunschdenken.....
    jemand eine Idee?

  • #2
    Da noch keiner geantwortet hat der VB beherrscht hier mal wie das in C# aussieht. Du mußt, damit das funktioniert, den System.Reflection Namespace hinzufügen.

    [Highlight=C#]string propName = "Visible";
    bool propValue = true;

    PropertyInfo propertyInfo = mycontrol.GetType().GetProperty(propName);
    PropertyInfo.SetValue(mycontrol, propValue , null);[/Highlight]

    Comment

    Working...
    X