Thank you for reaching out.
You can add an icon before each compartment item by customizing the paint logic of the compartment. The correct way is to override the PaintItem method in the generated compartment class (derived from ElementListCompartment). This method is called for each item, so you can draw an image and then the text.
Example syntax:
protected override void PaintItem(Graphics g, Rectangle bounds, int index)
{
Image icon = Properties.Resources.MyStreetIcon; // your icon
g.DrawImage(icon, bounds.Left, bounds.Top);
bounds.X += icon.Width + 4; // shift text
base.PaintItem(g, bounds, index);
}
Why this works: DSL Tools allow custom rendering by overriding paint methods. Creating a new GeometryShape won’t help because compartments don’t support embedded shapes. Overriding PaintItem is the simplest and supported approach.
Reference:
Here are the correct Microsoft Learn links for your scenario:
- Properties of Compartment Shapes
- CompartmentShape Class API
- Customizing and Extending a Domain-Specific Language
- Overview of DSL Tools
These pages explain how to customize compartment shapes, override paint logic, and extend DSL projects in Visual Studio.
Please let us know if you require any further assistance, we’re happy to help.
If you found this information useful, kindly mark this as "Accept Answer".