jeudi 10 septembre 2015

How to set properties(Drawing.Point) at runtime?

We created a new Drawing.Point dynamically at runtime and it works fine, now we want to set the properties "X" and "Y" at runtime. We tried to do it like this:

    Public Function SetObjectProperty(propertyName As String, value As Integer, refObj As Object)

    Dim propertyInfo As PropertyInfo = refObj.GetType().GetProperty(propertyName)

    If propertyInfo IsNot Nothing Then

        propertyInfo.SetValue(refObj, value, Nothing)
        Return refObj
    End If
    Return Nothing
End Function

But it didn't work. The properties aren't set with the values. Did we miss anything?





Aucun commentaire:

Enregistrer un commentaire