Solved

Displaying another field values

Posted on 2000-05-09
3
192 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
[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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month6 days, 6 hours left to enroll

627 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