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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top