Jump to content

Recommended Posts

Posted

I have the following code:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniButton1.Color := clRed;
end;

However the button color does not change.

How can I change the background color?

 

Posted

I need to change the background color at runtime based on the user that has logged in.

In other words I need to be able to change it dynamically.

 

 

Posted
5 minutes ago, mos said:

I need to change the background color at runtime based on the user that has logged in.

In other words I need to be able to change it dynamically.

Also this post may help you:

 

  • Like 1
  • 3 months later...
Posted

Hello Sherzod,

If i use a more simple method (CSS), i have the result :

Putting this CSS on ServerModule > CustomCSS   and  bg on Unibutton1 > LayoutConfig > CLS

 

1. This gives the color

.bg {
  background-image: none;  
  background-color: green;
}

 

 

2. This Not :

.bg {
  background-color: green;
}

 

3. If I use a big font then it overlaps

How can i avoid overlap ?

Thx

1.png

Posted

Hello Unigueers,

Please Share your expertise !

 

Many of us don't share any thing, probably thinking it's elementary.
it's wrong !

I keep saying : "Share, Share, Share and more"  ... even if it's simple.  -->  This will save us a lot of time.

So, for Who just come to Unigui world, here is a simple way do set dynamically (at runtime) the Unibutton color Background.

Color Background,  say you ?   Yes ... as it's not obvious at all  (thx to Sherzod) :

 

    with UniButton1.JSInterface do
    begin
      JSCall('btnWrap.setStyle', ['background-image', '"none"']);
      JSCall('btnWrap.setStyle', ['background-color', 'rgb(0,128,128)']);
    end;

 

You can use :  https://www.w3schools.com/css/css_colors_rgb.asp

To convert Colors in rgb  and  rgba format  (a = Alpha = Transparency).

 

  • Like 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...