DBEdit to DBCombo 
Author Message
 DBEdit to DBCombo

I am trying to create an application using a simple databse.  I used
the database expert to crete the form using a table.  I want to allow
the user to select records by picking from a list in the combo box.
My problem is that once I change one of the DBEdits to a DBCombobox,
the combo box doesn't display any of the data.  I have set the table
to active and the other fields show data, but the combo box is
completely useless.  Someone on the delphi Talk mailing suggested that
I set the DataFiled and DataSource fileds, but these are set
correctly.  What am I doing worng?  Thanx.

/--------------------------------------------------------------------------\
| Don't follow me; follow the one I follow    |     Jason "Screech" Lee    |

| Don't turn away because of the believers.   |   Computer Science Major   |
| The True one is the Christ and not the      |                            |
| Christians.                     -- Detritus |   God on high, Electrify   |
\--------------------------------------------------------------------------/



Sat, 14 Mar 1998 03:00:00 GMT  
 DBEdit to DBCombo

Quote:

>I am trying to create an application using a simple databse.  I used
>the database expert to crete the form using a table.  I want to allow
>the user to select records by picking from a list in the combo box.
>My problem is that once I change one of the DBEdits to a DBCombobox,
>the combo box doesn't display any of the data.  I have set the table
>to active and the other fields show data, but the combo box is
>completely useless.  Someone on the Delphi Talk mailing suggested that
>I set the DataFiled and DataSource fileds, but these are set
>correctly.  What am I doing worng?  Thanx.

The list in a TDBComboBox is not filled automatically from the underlying
table. You must fill the Items property TStrings list yourself,
programmatically. The TDBComboBox is data-aware only for the *output* of
the value selected from the list. In doing this, where that value will be
placed is determined by the settings in the DataSource and DataField
properties.

If you want an automatically filled list, use the TDBLookupCombo component,
instead. This component also has DataSource and DataField properties, again
for *output*, but it also has a LookupSource and a LookupField. These two
latter properties are the source from which the list in the TDBLookupCombo
will be filled (the list from which selections will be made).

**************************************************************************
Steve Koterski
Local InterBase Server Technical Support
Borland International, Inc.



Sat, 14 Mar 1998 03:00:00 GMT  
 DBEdit to DBCombo

Quote:

>If you want an automatically filled list, use the TDBLookupCombo component,
>instead. This component also has DataSource and DataField properties, again
>for *output*, but it also has a LookupSource and a LookupField. These two
>latter properties are the source from which the list in the TDBLookupCombo
>will be filled (the list from which selections will be made).

Ok.  I did that.  That part is solved, but I am left with one final
question (I think ;).  How do I force the DBLookupCombo to display the
first record of the database when the app first starts up.  THe DBEdit
boxes display the data for the first record, but the combo box is
blank.  I can't find anyhting on it in the books.  Thanx for your help
and time.


------------------------------------------------------------------------
Just as I am; I am stiff-necked and proud. Jesus is for losers. Why do I
still play to the crowd? Just as I am; pass the compass please.  Jesus
is for losers. I' off about a hundred degrees. -- Steve Taylor



Wed, 18 Mar 1998 03:00:00 GMT  
 DBEdit to DBCombo

Quote:


>>If you want an automatically filled list, use the TDBLookupCombo component,
>>instead. This component also has DataSource and DataField properties, again
>>for *output*, but it also has a LookupSource and a LookupField. These two
>>latter properties are the source from which the list in the TDBLookupCombo
>>will be filled (the list from which selections will be made).
>Ok.  I did that.  That part is solved, but I am left with one final
>question (I think ;).  How do I force the DBLookupCombo to display the
>first record of the database when the app first starts up.  THe DBEdit
>boxes display the data for the first record, but the combo box is
>blank.  I can't find anyhting on it in the books.  Thanx for your help
>and time.

When the TDBLookupCombo is used in this manner -- to select records based
on a field value rather than selecting a value to insert into the current
record -- you will not have the DataSource and DataField properties set.
Without these properties set, establishing a beginning value must be done
manually. This would be done by setting the Value property of the
TDBLookupCombo to the field value from the other TTable. This code would be
issued in a procedure for the form's OnShow event. To ensure that the value
of the TDBLookupCombo remains synchronized with the data-aware components
connected to the other TTable, it should also be executed in a procedure
for the OnDataChange event for the TDataSource connected to that other (the
editing) TTable.

Assuming that the TDBLookupCombo is connected to Table2 and editing (with a
TDBGrid?) is through Table1, the syntax would look something like:

  procedure TForm1.FormShow(Sender: TObject);
  begin
    DBLookupCombo1.Value := Table1.Fields[0].AsString;
  end;

And for the OnDataChange event procedure, the same thing:

  procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
  begin
    DBLookupCombo1.Value := Table1.Fields[0].AsString;
  end;

**************************************************************************
Steve Koterski
Local InterBase Server Technical Support
Borland International, Inc.



Fri, 20 Mar 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. DBCombo Initially Blank

2. PickList for DBCombo?

3. DBCombo informations

4. DBCombo or DbList with Index into Field

5. DBCombo & DBList boxes

6. DBCombo Box Update

7. DBLookUpCombos vs DBCombos or Combos

8. d2:searching for special dbcombo

9. DBCombo Problem?

10. Dbcombo

11. Set datasource for DBedit at runtime?

12. DBEdit

 

 
Powered by phpBB® Forum Software