Subject | Re: [IBO] ListBox does not show data (2nd post) |
---|---|
Author | Helen Borrie (TeamIBO) |
Post date | 2002-03-12T11:09:45Z |
At 10:28 AM 12-03-02 +0100, Heri Bender wrote:
You are expecting TIB_ListBox to be "double-data-aware" like a
TIB_LookupCombo? It is isn't a double-data-aware control: you bind the
control to the datasource that points to the dataset which wants the value.
Datafield selects the column which is to be filled.
There is no datasource for the items - you must supply those yourself (and,
optionally, ItemValues which, if used, will be selected into the
datasource.dataset.datafield in place of the corresponding list item.
If you want to feed the items in from a query, use a TIB_Cursor (which will
not need a datasource comp.) Its SQL will be
Select distinct CREATED from OBJEKT.
Then
with myCursor do
begin
if not Prepared then Prepare;
First;
while not EOF do
begin
Listbox1.Items.Add(Fields[0].AsString); // or whatever casting you
need to get a string
Next;
end;
end;
You'll probably want to give this cursor its own transaction and put this
little operation inside a callable procedure, since you'll want to close it
down neatly once you have the data; and you might want to refresh it at
some points.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com
>HiHeri,
>
>Since nobody has replied to my question and I cannot see what I did wrong, I
>repost it again:
>
>
>My TestApp has on the main form (from the dfm file):
>
> object IB_Connection1: TIB_Connection
> DatabaseName = 'KULTINFO'
> end
> object IB_Query1: TIB_Query
> DatabaseName = 'KULTINFO'
> IB_Connection = IB_Connection1
> SQL.Strings = ('Select CREATED from OBJEKT;')
> end
> object IB_DataSource1: TIB_DataSource
> Dataset = IB_Query1
> end
> object IB_Text1: TIB_Text
> DataField = 'CREATED'
> DataSource = IB_DataSource1
> end
> object IB_Grid1: TIB_Grid
> DataSource = IB_DataSource1
> end
> object IB_LookupCombo1: TIB_LookupCombo
> DataSource = IB_DataSource1
> DisplayField = 'CREATED'
> end
> object IB_LookupList1: TIB_LookupList
> DataSource = IB_DataSource1
> end
> object IB_ComboBox1: TIB_ComboBox
> DataField = 'CREATED'
> DataSource = IB_DataSource1
> end
> object IB_ListBox1: TIB_ListBox
> DataField = 'CREATED'
> DataSource = IB_DataSource1
> end
>
>If I open the query (very simple one, only 3 records), I can see data in all
>controls, but not in the TIB_ListBox.
>
>What must I do in order to see the 3 records in the ListBox too?
You are expecting TIB_ListBox to be "double-data-aware" like a
TIB_LookupCombo? It is isn't a double-data-aware control: you bind the
control to the datasource that points to the dataset which wants the value.
Datafield selects the column which is to be filled.
There is no datasource for the items - you must supply those yourself (and,
optionally, ItemValues which, if used, will be selected into the
datasource.dataset.datafield in place of the corresponding list item.
If you want to feed the items in from a query, use a TIB_Cursor (which will
not need a datasource comp.) Its SQL will be
Select distinct CREATED from OBJEKT.
Then
with myCursor do
begin
if not Prepared then Prepare;
First;
while not EOF do
begin
Listbox1.Items.Add(Fields[0].AsString); // or whatever casting you
need to get a string
Next;
end;
end;
You'll probably want to give this cursor its own transaction and put this
little operation inside a callable procedure, since you'll want to close it
down neatly once you have the data; and you might want to refresh it at
some points.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com