?
Solved

DBLookupComboBox and DBGrid (Delphi 3)

Posted on 1999-01-21
17
Medium Priority
?
2,232 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
[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
  • 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
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!

 

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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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