alogrep 0 Posted December 6, 2024 HI. I just can't get to change the text color of a statictext; I have this code: num:=TStaticText.create(self); num.parent:=self; num.parentcolor:=false; num.StyleElements:=[]; rect:=wc.boundsrect; num.caption:=' '+inttostr(lastnumnum)+' '; num.font.name:='Arial'; num.font.color:=clred; I have tried setting StyleElements to sefont, to seclient, and also left it alone (seclient, sefont, seborder).. THe texct color is always black. They have made this really hard to change! Anybody knows the "magic trick" to change the color on a runtime created statictext? P.S. if the statictext is created at design time, Style Elements is all set (3), AND IT WORKS LIKE A CHARM. Share this post Link to post
Lajos Juhász 302 Posted December 6, 2024 (edited) Set the transparent property to false: var num: TStaticText; begin num:=TStaticText.create(self); num.parent:=self; // rect:=wc.boundsrect; // num.caption:=' '+inttostr(lastnumnum)+' '; num.caption:=' Test'; num.font.name:='Arial'; num.font.color:=clred; num.Transparent:=false; end; Edit. You have to use StyleElement only if your application is using VCL Styles. Edited December 6, 2024 by Lajos Juhász StyleElement Share this post Link to post