?
Solved

Setting typed properties at runtime?

Posted on 2001-07-25
2
Medium Priority
?
206 Views
Last Modified: 2010-04-06
Apologies if this question has already been asked somewhere but in that the search function is not fully operational I am unable to search extensively.  Anyway, I need to set the properties of a label at runtime. eg. MyLabel.Font.Color  
The information needed to set the colour is held in a string which is read in from a text file at runtime.  The text in the string is clRed and I'm trying to use it while dynamically creating the label component.  Delphi seems to complain about a type mismatch (TColor and string) and I'm not entirely sure how to get around it.
(Incidentally - it's not actually the colour of text that I'm trying to change, it's a custom component which I created myself and so this is an easier example to explain!)
Any ideas would be greatly appreciated.
Thanks,
Xanthe
0
Comment
Question by:xanthe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 200 total points
ID: 6316689
Hi xanthe@lc,

Delphi help:

function StringToColor(const S: string): TColor;
Description

Call StringToColor to reverse the translation performed by ColorToString. This method is useful for converting the strings entered by the user into useable TColor values.

The S parameter can be either the name of a built-in color constant such as 'clBtnFace', or the string representation of a valid TColor value such as '$02FF8800'.  StringToColor returns the TColor value that corresponds to the S parameter.

Note:     If the string identifier can only be the name of a color constant, use IdentToColor instead.
0
 

Author Comment

by:xanthe
ID: 6316838
Brilliant!  I see however, that the question I asked was not as straight forward as I had thought.  You will notice that I said that the actual application was not to do with colour but with a custom component I have written, I see now that I will have to modify the code I have written for this component to allow it to have a function to change between a string and a TArrowType(a thing I use in my component)....although how I do that - no idea?!  Anyway, I'll have a try and thanks again for your help and your quick response!
Xanthe
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question