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

List Box failure

I am creating a form with various DB compnents. All grids, combo boxes seem to work except a list box I am tring to generate. I can insert assign it data and fields but it simply will not display the data. What is going on?
0
jblangworthy
Asked:
jblangworthy
1 Solution
 
skyrider_tieusCommented:
Can you be more specific?
0
 
NetoManCommented:
listening...
0
 
simonetCommented:
Are you sure it's a TDBListBox (the data-aware version) ?

Are you linking it correctly to the datasource and setting the field name accordingly?

If the datasource's dataset active (is table or query open) ?

Alex
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ITugayCommented:
listening...
0
 
jblangworthyAuthor Commented:
Yes, it is a DBListBox. I have sorted the problem now anyway, thanks. I didn't realise I had to add the items to the list-box. I thought it would fill them in itself, like access does.
0
 
simonetCommented:
>I thought it would fill them in itself, like access does.

You can do that automatically in runtime, based on the existing different items in the table.

Suppose the TDBListBox is linked to the field DESCRIPTION of TABLE1, and you want all existing "descriptions" to be displayed at the dblistbox.

This will do it for you:
(you'll need a TQuery [Query1] component)

procedure FillDBListBox;
begin
  with Query1, DBListBox1 do
  begin  
    items.beginupdate;
    items.clear;
    close;
    sql.text := 'SELECT DISTINCT DESCRIPTION FROM TABLE1 ORDER BY DESCRIPTION';
    open;
    first;
    while not eof do
    begin
       items.add(fieldbyname('description').asstring;
       next;
    end;
    items.endupdate;
  end;
end;

Yours,

Alex
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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