Solved

Displaying another field values

Posted on 2000-05-09
3
182 Views
Last Modified: 2010-04-04
Imagine a TNumericField descendant named MYFIELD. Values contained in this field are integers. I want to somehow modify the field's value but only for displaying purposes. For example If the MZFIELD contains a value of 1 I want to display in DBGrid a string "one", if the value is 2 I want to display string "two" and so on. I have played a little with OnGetText event of TField but I always got an exception "'' is not valid integer value". I tried the code below also on TStringField and I've got no exception but all MYFIELD's values has disappeared. What Iam doing wrong. Please help, Ivo.

The code is:

TForm1.MYFIELDGetText(...)
begin
  if (Sender = MYFIELD) and Text = '1' then
    Text:= 'one';
end;
0
Comment
Question by:ivobauer
3 Comments
 
LVL 6

Expert Comment

by:Jaymol
ID: 2791994
Handle the conversion in whatever component it is that you use to show the value, not in the actual field.

John.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 2792001
hi ivo,

you must lookup to sender fieldvalue like

GetTextEvent
begin
  if (Sender = MYFIELD) then
    If Sender.AsInteger = 1 then
      Text:= 'one'
    else
      Text := Sender.AsString;
end

also you must do a vice-versa with SetText like

SetTextEvent
begin
  if (Sender = MYFIELD) then
    If Text = 'one' then
      Sender.AsInteger := 1;
    else
      Try
        Sender.AsInteger := IntToStr(text);
      except
        raise;
      end;
end

hope this helps

meikl
0
 
LVL 2

Author Comment

by:ivobauer
ID: 2799798
Meikl: Thanks for the proposed answer, it helped me a lot again! I am transferring the points to your account. Do you remember when we talked about an updatable query? Can you send me your e-mail (I lost it) to Ivo.Bauer@upce.cz, I have something to say to you.
Once more - thanks to you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 303
oracle global variables 4 68
delphi parse string to params 3 122
Breakpoint doesn't stop in my variable 3 24
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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