Solved

Dblookuplistbox setting a selection

Posted on 2001-08-30
6
1,079 Views
Last Modified: 2010-05-18
Hi,

is it possible to set the selected item in a dblookuplistbox ? when i check the selecteditem property it has the value of the 1st thing in the list but it isn't selected (blue box around it) is it possible to set this blue box myself so it is selected.

I think it was possible with a normal listbox but i can't seem to find how to do it with a dblookuplistbox

thanks
0
Comment
Question by:joyrider
6 Comments
 
LVL 4

Expert Comment

by:YodaMage
ID: 6442001
I believe since a DB list box is intended to be linked to a data source, then just like a dbgrid, your selected value is not going to be based on an index but rather were the pointer currently resides in your dataset.
0
 

Author Comment

by:joyrider
ID: 6442106
so u can't actually selected it ? like u can when u select it with ure mouse ? or can it ?
0
 

Expert Comment

by:Pedja
ID: 6442120
I haven;t tried this, but since dblistbox is linket to data source, as I remember, when you open the list, blue box is set to item which shows current value of the field.
So, all you have to do is to set value of the field to wanted value before listbox is openned. However that means you will loose prevois value of the field.

I think waht you want to do (setting default value for the listbox) is not "polite" way to do it. It is beter to set default value to the field on record creation, not to change it when user enters that specific field. Second ay will confuse user.

Pedja

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Accepted Solution

by:
Jacco earned 25 total points
ID: 6442570
Hi JoyRider,

If you do

tblTest.Edit;
tblTest.FieldByName('MYFLD1').AsString := 'TEST';

If the field MYFLD1 is coupled to a TDBLookupListbox the item will be automatically selected.

Or maybe,

tblTest.Edit;
tblTest.FieldByName('MYFLD1').AsString := dbllbTest.Items[3]

Didn't test this though

Regards Jacco

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6443515
just modify the keyfield
0
 

Author Comment

by:joyrider
ID: 6444406
still don't have a blue box around it but at least i know there's always a value so not really a problem thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

14 Experts available now in Live!

Get 1:1 Help Now