Search code examples
c#winformsdesign-guidelines

Adding a legend for colors in ListView WinForms C#


I have simple ListView with few columns and it's populated with data with background colors. There's like 5 colors in use so I would like to nicely show them next to ListView for easy reminder especially for people who list things once a month.

Are there some kind of guidelines how to proceed with this before I start to do it on my own (GroupBox with Colored Labels describing meaning comes to my mind next to ListView)?


Solution

  • There are 101 ways of putting a legend together and a GroupbBox with colored Labels is just fine. The one consideration you should make though is whether the legend will need to be dynamic. I.e. will the colors ever need to change or be added to in the future. If yes, then you should code it so that it is dynamic. You can still use a group box and labels but assemble the legend according to a data model rather than static controls with hard coded colors.

    For other considerations: you could make it a user control that can dragged and dropped onto a Form and expose properties such as colored label size (length/width), label font, margins etc.