PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Programming the colors in a table
Programming the colors in a table
Débuté par Volker Gericke, 10 aoû. 2025 13:59 - 2 réponses
Posté le 10 août 2025 - 13:59
Hello,

Every table contains several colors depnding on the state of the row.
We have rows with odd line numbers, rows with even line numbers and we have a selected row (or selected rows).
It is rather easy to modify these colors using the table description.

But when I try to program this myself, I encounter difficulties as I only have two variables: Color (for the font) and Backgroundcolor (for the background).

Can anyone tell me how I can program the colors of the rows specifically?

Thank you and kind regards,

Volker
Membre enregistré
127 messages
Posté le 13 août 2025 - 10:03
In the Event "Displaying a row of the Table control" of your Table-Control use something like this:

//Your decission, what kind of backgroend is to use (here for ex. a simple modulo calculation)
SWITCH Modulo(MySelf,4)
CASE 0
MySelf[MySelf]..BackgroundColor = LightBlue
CASE 1
MySelf[MySelf]..BackgroundColor = LightGreen
CASE 2
MySelf[MySelf]..BackgroundColor = LightRed
CASE 3
MySelf[MySelf]..BackgroundColor = LightYellow

OTHER CASE
//Nothing
END
Posté le 13 août 2025 - 10:30
meikl wrote:
In the Event "Displaying a row of the Table control" of your Table-Control use something like this:

//Your decission, what kind of backgroend is to use (here for ex. a simple modulo calculation)
SWITCH Modulo(MySelf,4)
CASE 0
MySelf[MySelf]..BackgroundColor = LightBlue
CASE 1
MySelf[MySelf]..BackgroundColor = LightGreen
CASE 2
MySelf[MySelf]..BackgroundColor = LightRed
CASE 3
MySelf[MySelf]..BackgroundColor = LightYellow

OTHER CASE
//Nothing
END


Thank you Meikl,

That works fine and helps a lot.
Is there also a way to control the selected bar?

Kind greetings,

Volker