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

4 Years
Discussion Span
Last Post by Reverend Jim

You'd have to create the dictionary as

Private myDict As New Dictionary(Of String, Textbox)

and you could do

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

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


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


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.