Bob,
a Structure is a value type, which means you get a copy each time you assign
it to an object "variable" (rtbl.Tag) and each time you retrieve it from an
object "variable". As it will be boxed (placed on the heap).
In this case when you access rtbl.Tag.Url you are setting a property on a
copy of your initial structure.
If rtbAuxInfo "needs" to be a structure (which IMHO obviously doesn't, as
you are using it as a reference type). You need to make a copy, set the
copy, then save the copy. Something like:
| rtb1.Tag = New rtbAuxInfo ' at least this syntax seems OK
Dim temp As rtbAuxInfo = DirectCast(rtbl.Tag, rtbAuxInfo)
temp.URL = url
rtbl.Tag = temp
If you simply make rtbAuxInfo a Class, then you can simply refer to it in
the Tag property:
DirectCast(rtb1.Tag, rtbAuxInfo).URL = url
As the Tag property is returning a reference to a single object on the heap,
no copies of values is being done.
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"eBob.com" <fa******@totallybogus.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
|I know that this must be a really dumb question but I just can't find an
| answer.
|
| I want to associate some information with a RichTextBox. The Tag property
| seems to be the intended way to "hang" some additional information on a
| Control. I've created a structure, rtbAuxInfo, for the information. I
| think that I have found the right syntax for assigning a pointer to the
| structure to the Tag property of the RichTextBox, but I can't figure out
how
| to then assign a value to one of the fields of the structure.
|
| ' rtb1 is the RichTextBox
|
| rtb1.Tag = New rtbAuxInfo ' at least this syntax seems OK
|
| ' now I want to set the URL field of the rtbAuxInfo structure ...
|
| rtb1.Tag.URL = url ' doesn't work but I think that it shows what I am
| trying to accomplish
|
| CType(rtb1.Tag, rtbAuxInfo).URL = url ' doesn't work either
|
| I'd sure appreciate it if someone could help me with this.
|
| Thanks, Bob
|
|
|