I actually have a PopupMenu to choose the default template in a Window.
But that template is an image with different background color(s), and I have to modify this part of the project, so I take the opportunity to slicy modify my project.
S, I moved the PopupMenu out of the window and set a ListBox at its place.
Some small adjustments and simple additions were enough to display my (resized to fit in a ListBox Row) images.
All is nice and “working”, but the ListBox Row is “Selected” and this selection rectange hides the image.
I draw the image in the ListBox.CellBackgroundPaint Event.
The ListBox is hilighted while pressing the arrow key to change Row (Image and Text are hilighted).
There is only one visible Row.
I added Return True and now I can see the icon (the color of the icon) but with the selected Color that are above the Icon and the Text, the selection of the Colored Icon is a bit difficult.
This is a Template Icon and the only difference between all of the templates is/are the color (sometimes one color, sometimes two colors).
Th idea is to let the user to choose based on color (it was based on my name for the color…) with a little help (my color name)
If you want to remove the highlight, you can draw a white rectangle in the CellBackgroundPaint event (don’t forget to return true).
Then, you’ll also have to make your text black, as white on white will be unreadable; draw the cell in the CellTextPaint event, turning the colour to black (and returning true).
Actually, I already draw the icon in CellBackgroundPaint, and I also already used Return True.
Oh, and my text is Black (this, I know, does not looks like that in the screen shot). The automatic hilight turns it to white, not me. The ListBox draw the Text, not me.
I have the icon in one column and the text in the other column.
Yes, I know. As soon as you highlight a row in a listbox and the highlight colour is “dark”, the OS (or framework, whatever) draws its text as white. That’s why I suggest you to draw your text manually as black in the CellTextPaint event.
you have darkmode enabled and you expect a other color?
it looks like windows 10 hi light color.
this should draw the selected backbround in own colors
Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) Handles CellBackgroundPaint as Boolean
If column = 0 Then
If Me.Selected(row) Then
g.DrawingColor = Color.Red
Else
g.DrawingColor = Color.White
End If
g.FillRectangle(0,0,g.Width,g.Height)
g.DrawingColor = Color.Green
g.FillRectangle(0,0,10,10)
Return True
End If
End Function