Hi,

I have a number of non-visual components which I am trying to get the
name of at run time.

I have managed to reference each component using the following:

Dim pf As Type

pf = f.GetType
Dim fi As FieldInfo = pf.GetField("components",
BindingFlags.Instance Or BindingFlags.NonPublic)
' Dim o As Object =
Dim cl As IContainer = CType(fi.GetValue(f), IContainer)
Dim cm As Component

For Each cm In cl.Components
... etc

The cm.name gives me the type name of the object whereas I need the
actual name that the uer entered.

Am I going about this the correct way, is it possible to get this
info?

Thanks in advance

RE: Listing Non-Visual Component Names at Runtime by Craig

Craig
Tue Dec 25 13:07:00 CST 2007

Did you find an answer to your question? I too need the Component name at
runtime and I don't see it with reflection. Please help.

Thanks!



"d-barton@ntlworld.com" wrote:

> Hi,
>
> I have a number of non-visual components which I am trying to get the
> name of at run time.
>
> I have managed to reference each component using the following:
>
> Dim pf As Type
>
> pf = f.GetType
> Dim fi As FieldInfo = pf.GetField("components",
> BindingFlags.Instance Or BindingFlags.NonPublic)
> ' Dim o As Object =
> Dim cl As IContainer = CType(fi.GetValue(f), IContainer)
> Dim cm As Component
>
> For Each cm In cl.Components
> ... etc
>
> The cm.name gives me the type name of the object whereas I need the
> actual name that the uer entered.
>
> Am I going about this the correct way, is it possible to get this
> info?
>
> Thanks in advance
>
>