• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 659
  • Last Modified:

TDBLookupListBox & TDBLookupComboBox question

How to make a record active and currently selected for DBLookupComboBox and DBLookupListBox?

DBLookupComboBox1.ListSource := mDBTables_Module.ds_ItemCategory;
DBLookupComboBox1.KeyField   := 'CODE';
DBLookupComboBox1.ListField  := 'SHRTDESC';

DBLookupListBox2.ListSource := mDBTables_Module.ds_ItemEntry;
DBLookupListBox2.KeyField   := 'LONGDESC';
DBLookupListBox2.ListField  := 'LONGDESC';

Both do not have any datasource and datafield (because i use both for item selection only)

My problem now is how to make the first record selected (highlited with blue)?
0
girlswants_me
Asked:
girlswants_me
  • 5
  • 2
1 Solution
 
girlswants_meAuthor Commented:
anybody
0
 
girlswants_meAuthor Commented:
I'm using Delphi 7

When the form load automatically the first record in the table is selected (highlighted)
0
 
kretzschmarCommented:
not sure what you mean,
but try to set the property keyvalue to the value you need

meikl ;-)
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!

 
girlswants_meAuthor Commented:
where can i find the keyvalue???
When the form load automatically the first record in the table is selected (highlighted) <---this is for the DBLookupListBox2
0
 
girlswants_meAuthor Commented:
The first time the form load, i want that my DBLookuplistbox2 should have the first record highlighted or selected.
0
 
kretzschmarCommented:
use the afteropen-event of your lookupdataset like
(dataset is in the desired order and not empty)

procedure TForm1.ADOTable1AfterOpen(DataSet: TDataSet);
begin
  DBLookupComboBox1.KeyValue := DataSet.FieldByName(DBLookupComboBox1.KeyField).Value;
end;

meikl ;-)
0
 
girlswants_meAuthor Commented:
Meikl ;-) YOUR ARE GENIUS!!!! Thank you very much... I raised the points by 25

please see below for the solution.

 mDBTables_Module.db_ItemEntry.First;
 mDBTables_Module.db_ItemCategory.First;
 DBLookupComboBox1.KeyValue := mDBTables_Module.db_ItemCategory.FieldByName('CODE').Value;
 DBLookupListBox2.KeyValue := mDBTables_Module.db_ItemEntry.FieldByName('LONGDESC').Value;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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