Solved

Can't get picklist to work in DBGrid

Posted on 1998-04-01
10
501 Views
Last Modified: 2010-04-06
I've got a dataset in a Microsoft SQL server environment. A field in the dataset is of type integer and contains fixed values 0 and 1. 0 means the payment was cash 1 means a bill has to be sent. I want the 0's en 1's to be displayed as translated text in the grid. According to the manual this should be possible by setting the ButtonStyle to cbsAuto and enter the translate list in the  PickList property.

I've tried this over and over but the numbers keep appearing and not the text from the PickList.

The manual states that the Table Field has to be a lookup field. But the only lookup fields I can create needs another table.
0
Comment
Question by:paulsinn
  • 5
  • 4
10 Comments
 

Author Comment

by:paulsinn
ID: 1361175
Edited text of question
0
 

Expert Comment

by:phillipf
ID: 1361176
Do you want this field to be edited or is it just for display purposes?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361177
PS. why not using a byte as field type? You only use 0 and 1! Regards, Zif.
0
 

Author Comment

by:paulsinn
ID: 1361178
Philipf
I just want to display.

ZifNab
I'm not using a byte value because the number of states might very well rise over the 256 boundary in the future. Besides where talking very small databases here!
0
 

Expert Comment

by:phillipf
ID: 1361179
Try This:

  Create a new calculated field of type string.(the size is completly up to you).  Then on the TTables OnCalcFields Event assign this new field a value based on the value of your interger field.

Below is what the TTables OnCalcFields event might look like.

procedure TForm1.Table1CalcFields(DataSet: TDataSet);
begin
  If Table1CashPay.Value = 0 Then
    Table1CashDesc.Value := 'Cash'
    Table1CashDesc.Value := 'Not Billed';
end;

Now if you don't want the users to see the integer field just set it's visible property to false.

I hope this helps.
 
 
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:paulsinn
ID: 1361180
phillipf

This probably will work but I don't want to be coding an endless if - then - else construction if more state arise. The anwer you gave doesn't solve the picklist problem. It creates a detour. Thanks anyway. I'm going to reopen the question for other experts.

Paul.
0
 

Expert Comment

by:phillipf
ID: 1361181
Would you have any objections to creating another table to be used to lookup these descriptions?  Since the number of states is going to be unknow (sorry I thought there were going to be only two) then this would probably be your best bet?
0
 

Author Comment

by:paulsinn
ID: 1361182
The issue isn't the lookup problem but why it won't work with the picklist as is documented in the manual. If I have to create a table for every lookup the number of tables will grow exponentionally!
0
 

Author Comment

by:paulsinn
ID: 1361183
philipf please read.

I earlier rejected Your answer on my problem. I've now come to the conclusion that that is the only way to do it. I've interpreted the Picklist wrong. I thought the Picklist would automatically translate info from the field to the picklist and visa versa but it doesn't. I think you're entitled to the points. Respond to this message and you'll get them.
0
 

Accepted Solution

by:
phillipf earned 100 total points
ID: 1361184
Paulsinn,

  I realize it is not the most graceful solution but unless you want to use lookup tables it is probably your best bet.


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now