views:

123

answers:

1

How do I auto highlight the 1st entry in a DBLookupListBox without the end user highlighting it.

procedure TForm2.FormCreate(Sender: TObject);
begin
  Form2.ActiveControl := DBLookupListBox1;
end;

But this doesn't work, I've also tried DBLookupListBox1.setfocus on form create, but this gives an error, because the DBLookupListBox is not created yet.

Thanks

-Brad

+1  A: 
Jørn E. Angeltveit
I don't need to set the default values, just make sure it's highlighted.
Brad
Why would you want the DB-aware component to show a value that doesn't actually exist in the DB? Because this is what the highlighting is all about - representing the DB-value.When the user inserts a record, the DB-aware component should show the actual value for this field. Not something else.If the dataset is empty, then there is no value to show in the DB-aware component...
Jørn E. Angeltveit
The data exists in the database. I just want it to show the 1st item selected and highlighted, so that you know that item is the one in question. It auto selects the 1st item but it does not show it highlighted.
Brad
Sorry, I can't manage to reproduce this situation. In my case the proper item is selected and highlighted. :-(
Jørn E. Angeltveit
it's selected in my case also, but not highlighted... :(
Brad
One last question: Are you sure that the LookupValue and DataField items match? The selected but not highlighted state occurs when the DataField value isn't found in the lookup-table. We haven't delved into the details here, but if the LookupValue is a string field, for instanse, it is important that both values match in case and space. If the DataField is defined with Size=3 and FixedChar=True. Then the lookup table must have 'A ' (as in #65+#32+#32) as the LookupValue, not 'A' or 'a '.
Jørn E. Angeltveit