Get object member by name

  • Thread starter Thread starter Stefan Uhlemann
  • Start date Start date
S

Stefan Uhlemann

if i instance a new form... is it possible to get it´s member by name?

for example instead of:

Dim Button As Windows.Forms.Button = Form1.Button1

using

Dim Button As Windows.Forms.Button =
GetInstanceByName("Form1.Button1")

i tried CallByName but with this i can only get public members.
Is it possible to do this (within same project, of course) for friend
modifiers, too?

thanks...
 
Thanks Patrice,

Works great:

Dim PI As Reflection.PropertyInfo =
Form1.GetType.GetProperty("Button1", BindingFlags.Public Or
BindingFlags.NonPublic Or BindingFlags.Instance)
Button = PI.GetValue(Form1, Nothing)

Stefan
 
Back
Top