Solved

Can't get picklist to work in DBGrid

Posted on 1998-04-01
10
511 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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
 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

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