Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dblookuplistbox setting a selection

Posted on 2001-08-30
6
Medium Priority
?
1,171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Accepted Solution

by:
Jacco earned 75 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

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.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 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