Question

I am creating a Visual Studio Package for VS 2010 using VB.Net that contains a custom editor. The editor presents many items in ListViews. I want the item selected (its parent and any child items) to appear in the PropertyGrid panel object list to allow for property edits. I have this working. Normally the drop down list of selectable items appears with the name of the item in bold text followed by the type name for that object. In my package I cannot get the bold name to appear, only the type name.

http://msdn.microsoft.com/en-us/library/vstudio/bb165752(v=vs.100).aspx

This page is the only piece of information I can find on naming an object in the object list. As the link states, I implemented IProvideClassInfo in the objects I'm giving to VS to display in the list but the GetClassInfo method is never called and no name is displayed. Each object also has a public property called "Name" as well just in case that worked. It did not.

Can anyone tell me what I'm doing wrong?

Was it helpful?

Solution

Searching the forum on MSDN I finally found someone answering this question.

IProvideClassInfo has nothing to do with this like the link I gave states. The correct answer is to implement the ICustomTypeDescriptor interface in your objects. Most of the function implementations involve returning the result of the same function call on the TypeDescriptor object (shared/static functions). The GetComponentName result will be the bold part of the drop down. The GetClassName result will be the non-bold part. I'm not sure what the GetEditor function does but returning the TypeDescriptor.GetEditor result causes an infinite loop, returning Nothing/null seems to work.

I created a base class for all my objects that will go into the Property panel's drop down that implements all the functions where GetClassName returns Me.GetType().Name and GetComponentName returns Me.ToString()

It works great.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top