Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 2 Monaten
Letzter Beitrag:
vor 1 Jahr, 2 Monaten
Beteiligte Autoren:
Gianni Spano, Bill Quinn, Piet van Zanten, Fabrice Harari, cardcoder

[WB18] Change background color of a button

Startbeitrag von Gianni Spano am 05.05.2017 11:34

Hello to all

First, i apologize for this stupid question, but this is my situation:

i have 5 buttons .
At runtime, when the user push a button it must assume a RED Background color and the other remain GRAY as background.

this is the portion of code:

for j=1 to 5
if j=1 then

Unfortunately it seems that the bg color cannot be changed at runtime.
Is it right or do am i missing something?

This is a screenshot of the window

Thanks in advance


Hi Gianni,

You can change it at runtime.

I have had issues with the iteration. You would find it works with using the proper name of the button.

I have just done a quick test and it works,

I made cmd_button_colour.
server code, ajax "disabled"

IF Static_colour..BrushColor=LightRed THEN

This works correctly.
have a quick look on my site it is there at the moment -


von cardcoder - am 05.05.2017 12:35

this code should work -IF- the button is a TEXT button. If it uses am image for the background, then the image is ABOVE your background color and will not be visible

Best regards

von Fabrice Harari - am 05.05.2017 13:38
Hi Gianni,

Another thing to consider is that if you use indirection the affected controls need to be defined as "dynamic" type in the GUI tab.
Standard is "automatic", but since the controls are addressed via text, Webdev does not know the control needs to be dynamic.

Kind regards,

von Piet van Zanten - am 05.05.2017 19:35
Hi to all

Thanks for your suggestions


von Gianni Spano - am 08.05.2017 06:40

I just implemented this exact feature in WM21. As Fabrice noted, buttons with an image like those from a skin template have the background color hidden.

My code does this:

in global declarations:
gsXBtnImage is string = BTN_Antecedent..BackgroundImage

To change from the startup BG color:
BTN_Antecedent..BackgroundImage = ""
BTN_Antecedent..BrushColor = LightGreen

To return to the default BG:
BTN_Antecedent..BackgroundImage = gsXBtnImage


von Bill Quinn - am 11.05.2017 18:29
Hello Bill

Thanks for the tips


von Gianni Spano - am 12.05.2017 09:55
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.