Solved

DBLookupComboBox and DBGrid (Delphi 3)

Posted on 1999-01-21
17
2,053 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

19 Experts available now in Live!

Get 1:1 Help Now