Custom Controls lose their name at runtime Spy++/Automation (C#.Net)

I have various custom controls, such as Horizontal/vertical splitters, and other third party controls.  The problem is that Visual Studio's Spy++ and the White automation framework, are unable to obtain names from these components.

http://screencast.com/t/pctNZ94iwcW <-- Spy++ Screenshot, Selected component is a list box, which loses its name as well.

Can anyone tell me why they are missing?  And particularly, how to get them back?  perhaps there is a system setting/dev setting to retain it.  I have source project, and can alter the build if need be, though it would be best not to have to.
LVL 8
hpdvs2Asked:
Who is Participating?
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
This ones amuses me (maybe not you), so I fooled around a bit.

If you explore Spy++, you will see Caption in a few places, such as for searching, but never Name. Caption was used in the pre-.NET times for Text that is displayed but not editable by the user. I do not remember Name as a property of the controls at that time. I think it was only as an indication for the compiler. Somebody still working in VB6 might verify.

There does not seem to be a Text property in a UserControl or a ListView, but there is one, because UserControl inherits from Control. It has simply been hidden (look in help, it has the BrowsableAttribute set to False) because the designer of the class thought that it was useless. You can set the Text property of your UserControl in code even if it does not appear in IntelliSense. You will have to foor around a bit because IntelliSense will automatically enter something else, but you can edit the line afterward to keep Text alone. The control is then "captioned" as you want in Spy++.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Were the controls put on the form at design-time?...or run-time?
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
The Name is not automatic.

The Windows Form Editor generates code that fills in the Name property when you put a Control on the Form in design.

The same does not apply however when you add the controls through your code. This is probably what is happening there. Simply fill-in the Name property when you create the control through code.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
hpdvs2Author Commented:
These are for components that are added at design time.  The all have names in the properties window.
0
 
hpdvs2Author Commented:
This even includes ListView, as the screen shot shows on the highlighted record in the image.
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
I just ran Spy++.

It does not display the name of the controls, but their Text property. Controls in which the Text property is not set display an empty string.
0
 
hpdvs2Author Commented:
The problem is that many of these custom controls are from third party vendors.  So I cannot edit them.
0
 
hpdvs2Author Commented:
This has been out here for a while, and I have not found a better solution, It doesn't solve it the way I wanted, but it sounds like its just not possible in some general way.  The information just doesn't get translated along to the build.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.