Creating a ColorGroup
I selected your colors to create 2 color groups, called ColorGroup1 and ColorGroup2.
First I selected ColorGroup1 changed the selection from Named to Dual, selected the color on the left and enter your color definition D2FFF3, it has a opacity of 85%
then selected the color on the right, same definition D2FFF3 but opacity of 45%
Now ColorGroup2, D2EDF5, opacity of 85% for light, 45% for dark.
Now changed your CellBackgroudPaint Event to:
If row Mod 2 = 0 Then
g.DrawingColor= ColorGroup1
Else
g.DrawingColor= ColorGroup2
End If
g.FillRectangle(0, 0, g.Width, g.Height)
and this is how it looks in Light Mode:
and this in Dark Mode:
without changing anything else.
Now if you want to force the colors at 85% opacity (too bright for Dark Mode) then you need to handle the text colors (as you did with the CellTextPaint event). The problem with your code is that in Ligth Mode the listbox will look like this:
so is better to not change the default color for Light mode and let the system handle that (in other words remove the else … Color.White)
Without color group having the list box show the same alternate color in light and dark mode (after you handle the selected row text color), your listbox will look like this:
In normal mode (light)
In dark mode
I may not be available later today to help you if you can’t figure out how to use color.White on the selected row. I will add the code as spoiler. If you want to try yourself to figure it out don’t look at it
Text Paint code
If IsDarkMode Then
If Me.SelectedRowIndex = row Then
g.DrawingColor = Color.White
Else
// Change the Text Color for Dark Mode
g.DrawingColor = Color.Black
End If
End
Hope this helps with the use of Color Group and your final goal.