question

GlennCurrie-3093 avatar image
0 Votes"
GlennCurrie-3093 asked GlennCurrie-3093 commented

VB2015 Programming Question Accessing Object Properties

I want to access an objects properties using a string and not the specific object name. Example: Radio Button name is rdb11. Set a string variable strObject = "rdb11" then attempt to change the objects properties using the string strObject.Checked produces a build error.

windows-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LloydSheen-3317 avatar image
0 Votes"
LloydSheen-3317 answered GlennCurrie-3093 commented

What you are asking is really not the way to do things in WPF. Use MVVM to set properties (that are going to change). You end up with an object (ViewModel) that has properties that when changed will change the properties of the control in the UI that the property is bound to.

If you are bound to do what you ask you need to investigate reflection.

It seems that you want to create a line of code in a string and then execute it. To do this you should look into CodeDom.

I think what you are trying will in the long run not do you any good and the time to implement something like what you ask will be long and difficult

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LloydSheen: Thank you very much for the advice and the rapid reply.

0 Votes 0 ·