Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2003, 11:38 PM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default How can I use DBListBox (AGAIN) ?

Hi

I had a question about DBListbox few days ago.
The answer was good , but Ihad to insert data
manually , I was wonder how can I use DBListbox
as an automatic data list ?
I mean just tell it the datasource and datafield
and thats all ... Just like a gird ...

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
  #2  
Old 08-31-2003, 12:09 AM
moamo moamo is offline
Senior Member
 
Join Date: Aug 2003
Posts: 196
Default RE: How can I use DBListBox (AGAIN) ?

How do you want to use it?

1: Do you want to select an item and then watch the info from this line?(Like the Fish sample?)

2: Do you just want to show the list?

Tell a little bit more about your problem and I'll try to help you. I'm pritty sure it's possible. Check out all of the samples in the Delphi folder. Search for "DBListbox" in the help files.

I'm ready to help

greetings

Moamo
Reply With Quote
  #3  
Old 08-31-2003, 12:16 AM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default RE: How can I use DBListBox (AGAIN) ?

Thank you for your kind answer
I will explaint about it a little more ...

I have a database , I want to use a DBListBox to show
my items on it. I tried to set its DATASOURCE and
DATAFIELD , everything goes OK except it doesnt show
anything in the list ... have you ever tried it before ?
Thats kinda strange for me !

When I use another component suck like a gird ,
it can show my data but DBListBox doesnt show anything
except I insert my data manually which is not
my answer.

1) So imaging I have a Paradox database.
2) I have a DBListBox on my form
3) I have a DataSource and a table that is active

and now I want to show my data in the DBListBox without
using manula code , just to set the properties.
I did it , but didnt work , please try it once.
I know there is a way , please help me ...

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
  #4  
Old 08-31-2003, 12:18 AM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default RE: How can I use DBListBox (AGAIN) ?

I for got to tell somethine

Fish Fatc is a good sample but it doesnt use DBListBox .
My example is just like it , except I want to use
DBListBox <cr>WITH AUTOMATIC</cr> data detect.

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
  #5  
Old 08-31-2003, 07:17 AM
HTML HTML is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,977
Default RE: How can I use DBListBox (AGAIN) ?

Hi Raver

Try the DBLookupListBox component instead, if you need to fill it with the same values for the lookup and the connected dataset, just create another dataset and datasource pointing to the same table and see what happens.


The DBListBox is more like a DBComboBox it lets the user select a value for a field, the user can edit a field's value by selecting a item in the DBListBox and the table is posted. It doesn't actually show all the data and let the user edit data like a DBGrid would automatically do.

If you start navigating the table the DBListBox is connected to using a DBGrid or any other way you will see that if the field's value exists in the DBListBox that item will be automatically selected in the DBListBox, so if the field value is "test" then the "test" item will be selected. If a field value is not found in the list nothing is selected. To get started you would first need to add items to the DBListBox just as you would do in plain ListBox. That way you would have a better idea on how the DBListBox works.
Reply With Quote
  #6  
Old 08-31-2003, 07:46 AM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default RE: How can I use DBListBox (AGAIN) ?

I didnt get my answer
My I think I should forget about DBListBox !!!
Thank you

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
  #7  
Old 08-31-2003, 09:14 AM
HTML HTML is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,977
Default RE: How can I use DBListBox (AGAIN) ?

Raver,

Did you try to use the DBlookupListBox? it loads the items from a the ListSource table just as you want? Also set the ListField and KeyField properties to field you want to be listed in the control. The DataField and DataSource are optional properties to be set.
Reply With Quote
  #8  
Old 08-31-2003, 09:39 AM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default RE: How can I use DBListBox (AGAIN) ?

Yes my friend
It works , but my answer was about DBListBox as
one of my best friend is exactly looking for it.
Nobody knows the answer WHY IT DOESNT WORK AUTOMATIC ?

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
  #9  
Old 08-31-2003, 10:51 AM
HTML HTML is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,977
Default RE: How can I use DBListBox (AGAIN) ?

Hi m8.

The DBListBox is made to be filled by you not by getting values from a table as the DBLookupListBox does. It's just like a plain ListBox, where you can add items by

DBListBox1.Items.Add('some string');

Is there something you would like to do with the DBListBox that the DBLookupListBox can't?

If you like, this how you can add items from a table into a DBListBox but it isn't as efficient as using a DBLookupListBox.

var
recCnt,i: Integer;
begin

recCnt := Table1.RecordCount;
DBListBox1.Items.Clear;

Table1.First;
for i:=1 to recCnt do begin

DBListBox1.Items.Add(Table1.FieldByName('Field name here').AsString);

Table1.Next;

end;
Reply With Quote
  #10  
Old 08-31-2003, 10:59 AM
Raver Raver is offline
Senior Member
 
Join Date: May 2001
Posts: 525
Default RE: How can I use DBListBox (AGAIN) ?

Thank you for the answer
Thats correct , I can insert my data manually ,
But I was wonder why Delphi put DATASOURCE and
DATAFIELD in the properties of this component ?
I mean if cant get data from the table , why they
make DATASOURCE and DATAFIELD for it ?

Thank you for the answer again

<ct>
<tt>Kind Regards</tt>
R A V E R
</ct>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.