Stephen Westlake

Hi,

In the class diagram template, when using the DSL classes have a property "Superclass" which has a drop down populated with the names of all the other classes in the designer.

Could somebody tell me how this populated drop down is generated

thanks
Stephen


Re: Visual Studio Extensibility Property using populated drop down

Gokhan Altinoren

Hi Stephen,

You may provide your own type converter, generating list entries runtime. Here's a quick find using the search box above:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=71541&SiteID=1

Search for typeconverter to find more, like:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=335774&SiteID=1

Regards.

Gokhan




Re: Visual Studio Extensibility Property using populated drop down

Stephen Westlake

Thanks Gokhan, thats exactly what I was looking for. I'm still having a little trouble actually loading the values into the drop down.

I have a property in class A which will contain all the names of class type B. If I understand this correctly when overriding GetStandardValues() I should loop through all the type B elements and add their names to a list which is the return of GetStandardValues() I'm having a little trouble actually writing the simple code that loop through the elements.

Thanks

Stephen





Re: Visual Studio Extensibility Property using populated drop down

Edward Bakker

Stephen,

Have a look at some demo code below that works against a language based on the "Minimal Language" template. It basically tries to get a reference to the model root (ExampleModel) and loops through all elements. It uses the "Name" of the elements to populate the List that is returned as a StandardValuesCollection.

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)

{

List<String> elementList = new List<String>();

ExampleShape exampleShape = context.Instance as ExampleShape;

if (exampleShape != null)

{

ExampleElement exampleElement = exampleShape.ModelElement as ExampleElement;

foreach (ExampleElement element in exampleElement.ExampleModel.Elements)

{

elementList.Add(element.Name);

}

}

return new StandardValuesCollection(elementList);

}

Hope this helps

Edward





Re: Visual Studio Extensibility Property using populated drop down

Edward Bakker

Stephen,

Did the code example help or needs some more help

Edward





Re: Visual Studio Extensibility Property using populated drop down

Stephen Westlake

Yes, Thanks Edward I got that that working.

Stephen