Hello Don,
You wish to obtain this information at design-time, correct? At run-time
there is no reliable way to obtain this information. There is no way to
obtain the name either, if it is not serialized as a property in the
Component, as with Control. The only way to do this is via reflection on
members, and you are making a lot of assumptions if you start doing that.
That is, which fields were added by the designer, and which fields were
added outside the designer? How can you know?
If all your Component-derived classes have a Name property, then it will be
used both at design and run-time, and will be serialized and available at
run-time. But you cannot change classed created by other authors, to force
them to serialize a name.
At design-time, if you derive from Component you have a Container property
that should list all components known to the root designer. That includes
controls as well as components in the component tray.
Regards,
Frank Hileman
check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
> Hello all,
>
[quoted text clipped - 16 lines]
>
> Don Munroe
DRaiko - 18 Jun 2004 08:34 GMT
Hello Don,
if you really need component names at runtime, an easier way (no assumptions
about components created by other authors) is to subclass the containing
form and support some kind of dictionary {ComponentName -> Pointer} in it.
You can serialize the dictionary and thus use it at runtime. At design time
Component-Added/Removed/Rename must be handled. You can even recreate
the dictionary in EndInit() of the form or when the form is persisted.
(More reliable, since it can happen that components are
added/removed/renamed "manually" editing the text and no Component* event
will imform you about this.)
It works (i have had the same problem).
HTH,
dima
> Hello Don,
>
[quoted text clipped - 47 lines]
> >
> > Don Munroe