[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

Can't get picklist to work in DBGrid

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
paulsinn
Asked:
paulsinn
  • 5
  • 4
1 Solution
 
paulsinnAuthor Commented:
Edited text of question
0
 
phillipfCommented:
Do you want this field to be edited or is it just for display purposes?
0
 
ZifNabCommented:
PS. why not using a byte as field type? You only use 0 and 1! Regards, Zif.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
paulsinnAuthor Commented:
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
 
phillipfCommented:
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
 
paulsinnAuthor Commented:
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
 
phillipfCommented:
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
 
paulsinnAuthor Commented:
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
 
paulsinnAuthor Commented:
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
 
phillipfCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now