Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:18:50+00:00 2026-06-12T18:18:50+00:00

I am creating a Delphi form and want to assign background color to it

  • 0

I am creating a Delphi form and want to assign background color to it on run time. This code:

Form1.Color := clSkyBlue; 

works well. My problem is that I have stored the color name in a table as a string. So, when I fetch the color name from the table and assign it to Form1.Color, the above statement becomes:

var
  ColorName: string;
....
Form1.Color := ColorName;

and this results in a compile time error.

How can I convert a string to a TColor value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:18:51+00:00Added an answer on June 12, 2026 at 6:18 pm

    You can use the following conversion functions (both works with color constants):

    • the StringToColor function use to translate a string representation of a color to TColor value
    • the ColorToString function use when you need to translate TColor value to a string representation

    In your case you need to use the StringToColor function:

    Form1.Color := StringToColor('clSkyBlue');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on creating a custom form designer in the Delphi IDE. I'm
In Delphi 2007, images are loaded in a TImageList at design time. This introduces
I am creating a Delphi service. Is there any way to use controls derived
Using Delphi XE2 on Win 7 64 bit creating a 32 bit app... In
I'm creating a cache which is going to contain records in Delphi 2007. Each
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
I have a frame in a Delphi 2007 application that I want to embed
I have been toying around with creating soap servers in Delphi then running and
Is it possible to edit a DFM (Delphi's form script format) in such a
I'm currently confused about creating form using string form name (as in Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.