| Drop down list (DBLookupComboBox) inside a DBGrid - part 2 | ||||||||||||||||||||||
| Page 1: DBLookupComboBox in a DBGrid? | ||||||||||||||||||||||
This is the third article, in the series of articles named "Adding components to a DBGrid". The idea is to show how to place just about any Delphi control (visual component) into a cell of a DGBrid. If you are unfamiliar with the idea, please first read the "Adding components to a DBGrid" article.
In the first part of this article (second in the series), we've discussed about lookup fields, and what are the options of displaying a lookup field in a DBGrid, it's time to see how to place a DBLookupComboBox into a cell of a DGBrid to enable a user to pick a value for a lookup field from a drop down list box.
Here's how to place a DBLookupComboBox into a DBGrid. Create visually more attractive user interfaces for editing lookup fields inside a DBGrid - place a DBLookupComboBox into a cell of a DBGrid.
Now, take a look at the AuthorEmail field. Note that this field can only accept values from the Email field of the Authors table (defined by referential integrity). What you need to "see" in the picture below is that, when editing this field wit no lookup defined, if you try to edit a value to some value not found in the Authors table ("master" table), you'll get "You cannot add or change a record because a related record is required in table Authors" error message.
![]() What we are up against in this article is to make the above picture look like the one below: ![]() Ok. First we need to add several more components on a form along with a DBLookupComboBox. Next we have to set them up and do some Delphi magic ;) Next page > DBLookupComboBox in a DBGrid! > Page 1, 2 |
||||||||||||||||||||||



