Add Cell Viewing Form (dbExpress Tutorial)
A table cell may contain more data than can easily be viewed in the TDBGrid. This application displays a form containing the cell data when you click on a cell.
Add a form to the project by displaying the Project Manager in the right pane. Right-click on the project name DB_CDSDataUpdate and select:
- Add New > Form - Delphi for Delphi.
- Add New > Form - C++Builder for C++Builder.
Change the form's Caption to Current Field. Set the Name property to FormCurrentField.
- For Delphi, save this new unit as cdsfield.pas.
- For C++, save this new unit as cdsfield.cpp.
We want to display text, so add a TDBMemo component to the form. The TDBMemo component allows viewing and editing a dataset field. Set the TDBMemo's Name to "DBMemoCurrentField". Set all 4 parts of the Anchor property to true, so that when the form is resized, the TDBMemo fills the form.
The form now looks like this figure:
This form needs to be linked to the main form:
- For Delphi, add cdsfield to the
usesclause of cdsmain.pas.
- For C++Builder, add this line to cdsmain.h to reference the file just added:
The application is now complete.