Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display alternative value in DBGrid...?

Posted on 2002-07-17
10
Medium Priority
?
296 Views
Last Modified: 2010-04-04
Hi,

When I display the content of a database table in a DBGrid, all the boolean fields will display "true" or "false".

My question: how can I change this in order to see "yes" and "no" instead of "true" and "false" in the DBGrid component? Any other alternative value must be possible in order to support multiple languages.

Thank you in advance.

RoosieDB
0
Comment
Question by:roosiedb
[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
  • 3
  • 2
  • +1
10 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 7159166
You can use calculated field.

- Double click at the dataset that your dbGrid connected to.
- At fields editor right click and select Add all fields
- Right click again and select New Field
- At name box write YesNoField. At Type combo box select string and specify 3 in it's size field. At field type select Calculated.
- Display events tab of your datasource component, double click at OnCalcFields event and write:

  if DataSet.FieldByName('BooleanField').AsBoolean then
  DataSet.FieldByName('yesNoField').AsString:= 'Yes'
  else
  DataSet.FieldByName('yesNoField').AsString:= 'No'


I supposed that your boolean field called 'BooleanField'

Shufta kaif
Motaz
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7159177
you could also use the ongettext/onsettext-events of this field
0
 

Author Comment

by:roosiedb
ID: 7159293
Hi,

I will try this tonight... thank you in advance (for your quick reply)...

gr.,
RoosieDB
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 7159404
You can double click the Ttable and add all the fields, select your boolean field and in DisplayValues property.
You write for example Sí;No
or
Yes;Not
Oui;Non

As this property can be changed in runtime.

Best Regards
Marcos
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7159413
yep, marcos,
i was not sure,
because no delphi on hand
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 7159505
Danke Kretzschmar.
I forgot
Ja;Nein.

Best Regards
Marcos.
0
 
LVL 7

Accepted Solution

by:
Motaz earned 200 total points
ID: 7161269
There is a more easy solution without modifying any property :

after opening your table write:

  Table1.Open;
  TBooleanField(Table1.FieldByName('Bool')).DisplayValues:= 'Yes;No';


Motaz
0
 

Author Comment

by:roosiedb
ID: 7161775
For your information, I will use "JA" and "NEE" (as in Dutch)... Later on I will add some more languages in here...

gr.,
RoosieDB

P.S. Last night I did not have the chance to try this solution, I will retry tonight...
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 7162043
This is the idea. You can create a Global Variable for language that the user can select, and then write a function that returns the correct string.

Here you have an example and the idea you don't have more than to adapt it to your necessities.

Best Regards
Marcos.


procedure TForm1.Button1Click(Sender: TObject);
Var
cBoolShow:String;
nLanguage:Integer;
begin
nLanguage:=0;
Case nLanguage of
0:cBoolShow:='Ja;Nee';
1:cBoolShow:='yes;Not';
2:cBoolShow:='Oui;Non';
3:cBoolShow:='Ja;Nein';
4:cBoolShow:='Sí;no';
end;
Table1MyField.DisplayValues:=cBoolShow;
end;
0
 

Author Comment

by:roosiedb
ID: 7163081
Working perfect !

Thanx.

RoosieDB
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

719 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