Topic: Conditional coloring of label and panel
I was trying to color label and panel depending on combobox content on same form with the following but couldn't get the script constructed correctly:
procedure Form1_OnShow (Sender: string; Action: string); // for combo def index 0 which is Sale. However, combo doesn't show it somehow?
begin
begin
if Form1.cbSaleInvDBCR.text = 'Sale' then
begin
Form1.Label1.Caption := 'Sales Invoice'.color := clWhite;
Form1.Panel1.color := clBlue;
end
end;
procedure Form1_cbSaleInvDBCR_OnChange (Sender: string);
begin
if Form1.cbSaleInvDBCR.text = 'Sale' then
begin
Form1.Label1.Caption := 'Sales Invoice'.color := clWhite;
Form1.Panel1.color := clBlue;
end else
begin
Form1.Label1.Caption := 'Sales Credit Note'.color := clWhite
Form1.Panel.color := clRed;
end;
end;
Combo has two items in total.
Sale
Refund.
First empty item set to false
Default index set to zero
If needed please see the sample project attached:
God... please help me become the person my dog thinks I am.