Board index » delphi » Questions about DBComboBox and DBLoopkupComboBox controls

Questions about DBComboBox and DBLoopkupComboBox controls

Hi,

I would like to create a dropdown list from a datasource and select one item
from the list, so I tried to use the DBComboBox control.  When the
datasource is a TTable, DBComboBox works ok, both click and selection work,
however if the datasource is a TQuery, the click event does not work (the
code in that event does not fire) and I can not select one from the list
(when I select one, the text of DBComboBox does not change).  Is this the
way the DBComboBox is supposed to behave?

I also used the DBLookupComboBox control.  The problem is that the
DBLookupComboBox may return multiple rows with the same KeyField, so when I
do select from the dropdown list, all rows with the same KeyField are
highlighted (In fact, I only want to select one).  Is this the way the
DBLookupComboBox is supposed to do?

Thank you very much in advance.

Sheldon

 

Re:Questions about DBComboBox and DBLoopkupComboBox controls


Quote
>I would like to create a dropdown list from a datasource and select one item
>from the list, so I tried to use the DBComboBox control.  When the
>datasource is a TTable, DBComboBox works ok, both click and selection work,
>however if the datasource is a TQuery, the click event does not work (the
>code in that event does not fire) and I can not select one from the list
>(when I select one, the text of DBComboBox does not change).  Is this the
>way the DBComboBox is supposed to behave?

A dbcombobox is a control that is designed to use a list to put a value into a
database field.  I do not see how you are using it for the stated purpose?

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:Questions about DBComboBox and DBLoopkupComboBox controls


I didn't realize that a dbcombobox is a control that is designed to use a
list to put a value into a database field.  If I want to select one from a
list (from a table or query), but do not want to put value into database
field,  what control should I use?  a ComboBox (populated manually) or a
DBLookupComboBox?

Thanks.

Quote
Brian Bushay TeamB wrote in message <3640995e.47097943@floyd>...
>>I would like to create a dropdown list from a datasource and select one
item
>>from the list, so I tried to use the DBComboBox control.  When the
>>datasource is a TTable, DBComboBox works ok, both click and selection
work,
>>however if the datasource is a TQuery, the click event does not work (the
>>code in that event does not fire) and I can not select one from the list
>>(when I select one, the text of DBComboBox does not change).  Is this the
>>way the DBComboBox is supposed to behave?

>A dbcombobox is a control that is designed to use a list to put a value
into a
>database field.  I do not see how you are using it for the stated purpose?

>--
>Brian Bushay (TeamB)
>Bbus...@DataGuidance.com

Re:Questions about DBComboBox and DBLoopkupComboBox controls


Any control that starts with DB is designed to be used as a database
tool. If you just want a variable selected from a list, use a ComboBox
or Listbox.

Woody

Quote
Sheldon Wang wrote in message <7184ce$f...@forums.borland.com>...
>I didn't realize that a dbcombobox is a control that is designed to
use a
>list to put a value into a database field.  If I want to select one
from a
>list (from a table or query), but do not want to put value into
database
>field,  what control should I use?  a ComboBox (populated manually)
or a
>DBLookupComboBox?

>Thanks.

>Brian Bushay TeamB wrote in message <3640995e.47097943@floyd>...
>>>I would like to create a dropdown list from a datasource and select
one
>item
>>>from the list, so I tried to use the DBComboBox control.  When the
>>>datasource is a TTable, DBComboBox works ok, both click and
selection
>work,
>>>however if the datasource is a TQuery, the click event does not
work (the
>>>code in that event does not fire) and I can not select one from the
list
>>>(when I select one, the text of DBComboBox does not change).  Is
this the
>>>way the DBComboBox is supposed to behave?

>>A dbcombobox is a control that is designed to use a list to put a
value
>into a
>>database field.  I do not see how you are using it for the stated
purpose?

>>--
>>Brian Bushay (TeamB)
>>Bbus...@DataGuidance.com

Re:Questions about DBComboBox and DBLoopkupComboBox controls


Sheldon,

You can use a DBLookupComboBox. Leave the datafield and datasource
blank and only attach the items for the ListSource and KeyField. You can
optionally supply values for ListField.

Now your DBLookupComboBox should behave as a pick list.

Garry Kernan

Quote
Sheldon Wang wrote in message <7184ce$f...@forums.borland.com>...
>I didn't realize that a dbcombobox is a control that is designed to use a
>list to put a value into a database field.  If I want to select one from a
>list (from a table or query), but do not want to put value into database
>field,  what control should I use?  a ComboBox (populated manually) or a
>DBLookupComboBox?

>Thanks.

>Brian Bushay TeamB wrote in message <3640995e.47097943@floyd>...
>>>I would like to create a dropdown list from a datasource and select one
>item
>>>from the list, so I tried to use the DBComboBox control.  When the
>>>datasource is a TTable, DBComboBox works ok, both click and selection
>work,
>>>however if the datasource is a TQuery, the click event does not work (the
>>>code in that event does not fire) and I can not select one from the list
>>>(when I select one, the text of DBComboBox does not change).  Is this the
>>>way the DBComboBox is supposed to behave?

>>A dbcombobox is a control that is designed to use a list to put a value
>into a
>>database field.  I do not see how you are using it for the stated purpose?

>>--
>>Brian Bushay (TeamB)
>>Bbus...@DataGuidance.com

Re:Questions about DBComboBox and DBLoopkupComboBox controls


Quote
>  If I want to select one from a
>list (from a table or query), but do not want to put value into database
>field,  what control should I use?  a ComboBox (populated manually) or a
>DBLookupComboBox?

If I where going to limit my search to components that come with Delphi I would
probably use a CmboBox and populate it manually.
But of all the 3rd party components available there seem to be an ulimited
number of comboboxes that do various things so you may want to look around and
see if you can find one that does just what you want.

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:Questions about DBComboBox and DBLoopkupComboBox controls


To select a value from a table or query, use the DBLookupComboBox.  Fill in the
ListSource, ListField, and KeyField properties.  If you don't want to place the value
into a database field, just leave the Datasource and Datafield properties blank.  This
has worked fine for me in several applications.

I have noticed that if you use the DBLookupComboBox with a TQuery, it is a very good
idea to create persistent fields for the Query (otherwise you may get Access Violations
if the query is closing and reopening when the ComboBox is being clicked).

Hope this helps,  Brian

Quote
Sheldon Wang wrote:

> I didn't realize that a dbcombobox is a control that is designed to use a
> list to put a value into a database field.  If I want to select one from a
> list (from a table or query), but do not want to put value into database
> field,  what control should I use?  a ComboBox (populated manually) or a
> DBLookupComboBox?

Other Threads