0

Hi DaniWebbers,

I would like to map a string to a Property using the Dictionary class. For example, I want to map "port" to a textbox's Text property, e.g. myDict.Add(tbPort.Text, "port"). How would I go about defining the dictionary? I've tried the following:

  • Private myDict As Dictionary(Of Property, String)
  • Private myDict As Dictionary(Of [Property], String)

but these do not work, since Property is not a type.

Is this even possible? If so, how do I define the dictionary? If not, would I have to go about using reflection?

Edited by MonsieurPointer

2
Contributors
3
Replies
7
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

You'd have to create the dictionary as

Private myDict As New Dictionary(Of String, Textbox)
myDict.Add("port",TextBox1)

and you could do

myDict("port").Text = "some text"

You can't create a pointer (reference) to a property within an object (or control).

0

Thanks for the tip and sorry for the late reply, I did not receive any notification that you have posted something!

0

No problem. Check your profile to see if you have the following options set

Receive Email from DaniWeb?
Automatically Watch Articles I Post In?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.