DBLookUpCombos vs DBCombos or Combos 
Author Message
 DBLookUpCombos vs DBCombos or Combos

The following is noteworthy:  I have a table with 6000 records.  I need
to populate a Combo box with the contents of a field in the table to
comprise a pick list for the user.  I've imlemented it 2 different ways:

 1)  Using a regular DBComboBox or plain Combo Box, Iterate over all
6000 records, adding with FieldByName the values stored in the
particular field.  This takes about a MINUTE!

 2) Using a DBLookUpComboBox, binding the control to the datasource
representing the table, and defining the lookup properties accordingly.
This seems to happen almost IMMEDIATELY!

 The question is why?  If I wanted to populate a combo or DBCombo with
the same performance of the DBLookUpCombo, how  would I proceed?  You
(Borland) must have found a way to populate the control so quickly, and
we would much appreciate any tips you have. Thank you..



Sat, 18 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos


Quote:
>The following is noteworthy:  I have a table with 6000 records.  I need
>to populate a Combo box with the contents of a field in the table to
>comprise a pick list for the user.  I've imlemented it 2 different ways:

> 1)  Using a regular DBComboBox or plain Combo Box, Iterate over all
>6000 records, adding with FieldByName the values stored in the
>particular field.  This takes about a MINUTE!

> 2) Using a DBLookUpComboBox, binding the control to the datasource
>representing the table, and defining the lookup properties accordingly.
>This seems to happen almost IMMEDIATELY!

> The question is why?  If I wanted to populate a combo or DBCombo with
>the same performance of the DBLookUpCombo, how  would I proceed?  You
>(Borland) must have found a way to populate the control so quickly, and
>we would much appreciate any tips you have. Thank you..

The way I've used for populating a common or garden variety of ComboBox
is;

1. Bring the data into a data aware control such as a DBGrid. Hide this
behind a panel if you don't want it to show on screen.

2. Iterate the associated TTable using code such as

  Table1.Open;
  Table1.DisableControls;
  try
    Table1.First;
  while not Table1.EOF do begin
    ComboBox1.Items.Add(DBGrid1.Fields[1].AsString);
    Table1.Next;
  end;
  finally
    Table1.EnableControls;
  end;

3. Put this code in the OnShow event for the form which is the parent of
the ComboBox.

6000 items seems a lot for a humble ComboBox, but this technique works
rapidly for me with a Paradox table holding several hundred records.
--
Barney Tyrwhitt-Drake



Sun, 19 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos


Quote:
>The following is noteworthy:  I have a table with 6000 records.  I need
>to populate a Combo box with the contents of a field in the table to
>comprise a pick list for the user.  I've imlemented it 2 different ways:

> 1)  Using a regular DBComboBox or plain Combo Box, Iterate over all
>6000 records, adding with FieldByName the values stored in the
>particular field.  This takes about a MINUTE!

> 2) Using a DBLookUpComboBox, binding the control to the datasource
>representing the table, and defining the lookup properties accordingly.
>This seems to happen almost IMMEDIATELY!

> The question is why?  If I wanted to populate a combo or DBCombo with
>the same performance of the DBLookUpCombo, how  would I proceed?  You
>(Borland) must have found a way to populate the control so quickly, and
>we would much appreciate any tips you have. Thank you..

When you programmatically populate the list in a TDBComboBox component, you
need to iterate through all the records in the source data set, adding each
field value to an item in the TStrings type Items property.

On the other hand, the TDBLookupCombo does not read all record values
initially. Instead, it acts like other multi-value components (such as the
TDBGrid and TDBLookupList components) in reading into memory field values
from only as many records as need to be displayed. If field values from
other records need to be displayed (at run-time), such as when the end-user
scrolls the list, the field values from these additional records are read
at that time as needed. This is why the TDBLookupCombo appears to be so
much faster in populating itself than the TDBComboBo component.

**************************************************************************
Steve Koterski                    "Knowledge advances by steps, and not by
Product Group Manager             leaps."
Delphi Technical Support                       -- Lord Macaulay, 1800-1859
Borland International, Inc.



Tue, 21 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos
Hi Steve,

I read your mail about DBLookupCombo. Here are some more questions: is there
a way to display the contents of the DBlookupCombo sorted when using the
Local Interbase Engine ?
Since the DBLookupCombo is inherited from DBEdit an not from a DBCombo it has
no "sorted" property.
Why can I connect the LookupSource only to a table and not to a Query ? The
Local Interbase Engine will not allow me to add an "order by" statement in a
view, so I think there is no solution to this problem.

Any ideas ?
Damien



Wed, 22 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos
By the way: I have been an MS-Access-Programmer for a long time. Now I turned
to Delphi but there are many features I'm missing from Delphi. What is so
difficult in the Access-ComboBoxes so Delphi don't have them ?

Damien



Wed, 22 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos
On Wed, 31 Jan 1996 10:22:03 +0000, Barney Tyrwhitt-Drake

Quote:



>>The following is noteworthy:  I have a table with 6000 records.  I need
>>to populate a Combo box with the contents of a field in the table to
>>comprise a pick list for the user.  I've imlemented it 2 different ways:

>> 1)  Using a regular DBComboBox or plain Combo Box, Iterate over all
>>6000 records, adding with FieldByName the values stored in the
>>particular field.  This takes about a MINUTE!

>> 2) Using a DBLookUpComboBox, binding the control to the datasource
>>representing the table, and defining the lookup properties accordingly.
>>This seems to happen almost IMMEDIATELY!

>> The question is why?  If I wanted to populate a combo or DBCombo with
>>the same performance of the DBLookUpCombo, how  would I proceed?  You
>>(Borland) must have found a way to populate the control so quickly, and
>>we would much appreciate any tips you have. Thank you..

DBLookUpCombo is not based on a combobox but on an edit box.  The
items in the dropdown list are drawn on an as required basis.  As only
a small number of values are needed to be shown at any time (default
is 8 rows) very little data needs to be shifted.

Quote:
>The way I've used for populating a common or garden variety of ComboBox
>is;

>1. Bring the data into a data aware control such as a DBGrid. Hide this
>behind a panel if you don't want it to show on screen.

You don't need the control, all you need is a ttable.

Quote:

>2. Iterate the associated TTable using code such as

>  Table1.Open;
>  Table1.DisableControls;
>  try
>    Table1.First;
>  while not Table1.EOF do begin
>    ComboBox1.Items.Add(DBGrid1.Fields[1].AsString);

use
  ComboBox1.Items.Add(Table1.Fields[1].AsString);
instead

Quote:
>    Table1.Next;
>  end;
>  finally
>    Table1.EnableControls;
>  end;

>3. Put this code in the OnShow event for the form which is the parent of
>the ComboBox.

Probably better in the OnCreate event unless the Table is likely to
change a lot.

Quote:
>6000 items seems a lot for a humble ComboBox, but this technique works
>rapidly for me with a Paradox table holding several hundred records.
>--
>Barney Tyrwhitt-Drake

Sean


Thu, 23 Jul 1998 03:00:00 GMT  
 DBLookUpCombos vs DBCombos or Combos

writes
Quote:

>DBLookUpCombo is not based on a combobox but on an edit box.  The
>items in the dropdown list are drawn on an as required basis.  As only
>a small number of values are needed to be shown at any time (default
>is 8 rows) very little data needs to be shifted.

>>The way I've used for populating a common or garden variety of ComboBox
>>is;

>>1. Bring the data into a data aware control such as a DBGrid. Hide this
>>behind a panel if you don't want it to show on screen.

>You don't need the control, all you need is a ttable.

>>2. Iterate the associated TTable using code such as

>>  Table1.Open;
>>  Table1.DisableControls;
>>  try
>>    Table1.First;
>>  while not Table1.EOF do begin
>>    ComboBox1.Items.Add(DBGrid1.Fields[1].AsString);

>use
>  ComboBox1.Items.Add(Table1.Fields[1].AsString);
>instead

>>    Table1.Next;
>>  end;
>>  finally
>>    Table1.EnableControls;
>>  end;

>>3. Put this code in the OnShow event for the form which is the parent of
>>the ComboBox.

>Probably better in the OnCreate event unless the Table is likely to
>change a lot.

>>6000 items seems a lot for a humble ComboBox, but this technique works
>>rapidly for me with a Paradox table holding several hundred records.
>>--
>>Barney Tyrwhitt-Drake

>Sean

You're absolutely right, and I recall that I first used this duplication
of bringing the data into a data aware control and then copying it to
the combobox because it was giving an error somewhere else in the
program if I tried to do it directly. No problems with using the TTable
directly now and placing the code in the OnCreate event. Thanks.
--
Barney Tyrwhitt-Drake


Thu, 23 Jul 1998 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. DBLookupCombo box problem D1 vs D3?

2. DBLookupCombo vs. DBLookupComboBox

3. TTable vs TQuery vs TwwQuery vs TwwTable - SPEED

4. DBCombo Initially Blank

5. PickList for DBCombo?

6. DBCombo informations

7. DBEdit to DBCombo

8. DBCombo or DbList with Index into Field

9. DBCombo & DBList boxes

10. DBCombo Box Update

11. d2:searching for special dbcombo

12. DBCombo Problem?

 

 
Powered by phpBB® Forum Software