Solved

DBLookupComboBox and DBGrid (Delphi 3)

Posted on 1999-01-21
17
2,130 Views
Last Modified: 2008-02-20
Hello !

How to use a DBLookupComboBox in a DBGrid ?
I want to select the data of a table in a combobox-cell.
Can you give me an example ?

Thanx.
0
Comment
Question by:nk51
  • 6
  • 4
  • 3
  • +2
17 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362680
Hi nk51,

read this article : http://www.gnomehome.demon.nl/uddf/pages/dbgrid.htm#dbgrid1

regards, Zif.
0
 

Author Comment

by:nk51
ID: 1362681
The answer you give is for a DBLookUpCombo and not for a DBLookUpCombobox...
I try to use a DBLookUpComboBox with the proposed code but with no succes.


0
 
LVL 1

Expert Comment

by:velev
ID: 1362682
create lookup field in your DataSet (tquery or ttable)
and add a cloumn in your DBGrid that is attached to this field

but do not forget working with lookups is slow operation slow
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!

 

Author Comment

by:nk51
ID: 1362683
Can you explain the steps to do this with more details please ?

0
 
LVL 1

Expert Comment

by:velev
ID: 1362684
dblClick on your main dataset (tquery or tTable)
a window will popup
click btn add new field, another window will apear
adjust properties of the new field - make field lookup and adjust its properties( they are like this when adjusting properties for DBLookupCombo...)


dblClick on your DBGrid
add cloumn in the popuped window and set the field property of this column to above created field


0
 

Author Comment

by:nk51
ID: 1362685
I don't understand...Sorry. What about the DBLookupCombobox ?
0
 
LVL 1

Expert Comment

by:velev
ID: 1362686
the above procedure will help
DBGrid will use as InplaceEditor for such colomns (linked to lookup fields) component that has similar behavior to that of
DBLookup...



0
 
LVL 1

Expert Comment

by:adeng
ID: 1362687
Delphi DBGrid has its own DBLookupComboBox included, you don't have to make your own ! but if you do !?!

And about Zif proposed answer about DBLookupComboBox in http://www.gnomehome.demon.nl/uddf/pages/dbgrid.htm#dbgrid1 just rename your DBLookUpComboBox component name to DBLookUpCombo1 !

Regard, Adeng.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362688
nk51,

 here is another article if you haven't figured it out yet, with the other one.

Regards, Zif.
0
 

Author Comment

by:nk51
ID: 1362689
To velev : which above procedure ? I don't have a good english and perhaps I don't understand what you write but I don't understand your answer...

Adeng said that "Delphi DBGrid has its own DBLookupComboBox included, you don't have to make your own !".
Is it true ? Because It's better fo me.
How to use the own DBLookupComboBox of e DBGrid?
Thanx.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362690
hehe, forgot the article :

http://www.delumpa.com/tips/comps/comps10.htm

topic from Delumpa (writer of article)

Note: Some of you old hats at Delphi might immediately exclaim, "What's the use of this article? In Delphi 3, we have the capability of specifying a cell in a DBGrid to be a drop-down edit." Well, that's the thing, isn't it? You have to fill in the values of the Items property yourself. What I'm suggesting here is adding a TDBLookupComboBox that will enable you to look up information from another data source. This isn't available in ANY version of Delphi.
By the way, this isn't my original idea, and in fact, the technique has been around since Delphi 1. But it's valid and applicable to Delphi 3.


Regards, Zif.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 1362691
Hi nk51,

how to do,

the mastertable should contain the two fields of your lookuptable

example
mastertable

. Fields ... ,ALookupKeyField,ALookupResultField

LookUpTable

ALookupKeyField, ALookupResultField  (ALookupKeyField should be primary index)

drop the two tables, a datasource, a dbgrid on a form
set the propertys of these components, so that the grid shows your mastertable and both tables are active

deactivate your mastertable (property active = False)
doubleClick of the tablecompenentsymbol on your from, an empty columeditor pops up
rightclick on this editor, select insert fields om the popupmenu
the columeditor is now filled with the fields of your mastertable, select the ALookupResultField

set in the objectinspector now following propertys

KeyField = ALookupKeyField from your mastertable
LookUpCache = True
LookUpDataSet = YourLookUpTable
LookUpKeyFields = ALookupKeyField from your LookUpTabletable
LookUpResultField = ALookupResultField from your LookUpTabletable
FieldKind = ftLookUp

set your mastertable active
run your application

you will see that in your grid if you edit your ALookupResultField a dropdownbutton apears
on dropping down you see the entrys of your lookuptable

good luck on the try

meikl ;-)
0
 

Author Comment

by:nk51
ID: 1362692
Just what I needed.
The latest ZifNab's comment about the article : http://www.delumpa.com/tips/comps/comps10.htm 
said the same thing.
Thanx.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362693
Hi nk51,

i wondered about this fast evaluation.

zif,

sorry, i haven't read this article, i've figured out byself.

meikl
0
 

Author Comment

by:nk51
ID: 1362694
Your answer is the same as ZifNab.
And ZifNab answered the Monday, January 25 1999 - 10:56AM PST
and we are Friday, January 29 1999.
So I had all the time to try Delumpa's advices.  


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362695
... :-) I didn't answer.... I gave a comment .... ;-))

kretzschmar, no problem! Keep smiling!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1362696
:-) i smile ;-)
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 91
Base1 Encode/Decode 3 86
Tvertscrollbox like a whatsapp layout delete messages 1 38
DBCtrlGrid, Delphi, Scroll 8 57
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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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