Solved

DBLookupComboBox and DBGrid (Delphi 3)

Posted on 1999-01-21
17
2,026 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

23 Experts available now in Live!

Get 1:1 Help Now