Topic: Change form background with checkbox

Hi all,

does anyone knows if it is possible to change the background color of a form according to the status of a checkbox?

e.g: I have an edit form with a default blue background and if one specific checkbox if ticked, I would like the background to change to red

Re: Change form background with checkbox

Hi TCOTON,

I do much the same thing when the value in an edit field changes - I imagine it's exactly the same for a checkbox.

procedure form1_Edit1_OnExit (Sender: string);
begin
  if   form1.edit1.text   =     'ABC123'  then form1.color := $0066CCFF;
  if   form1.edit1.Text <>   'ABC123'  then form1.color := $00DCD9AF;
end;

Hope it helps and good luck,

Derek.

3 (edited by tcoton 2015-10-16 13:34:08)

Re: Change form background with checkbox

Oh, is that simple as that? smile



I used this script

procedure Form1_OnShow (Sender: string; Action: string); 
begin
if Form1.Checkbox1.Checked then Form1.color := $003333FF else Form1.color:= $00FFCC99; 
end;

Works like a charm

Thanks Derek

Re: Change form background with checkbox

Hi tcoton,
I only answer the easy ones - LOL!  I leave the complicated stuff to Dmitry!
Derek.