Putting DBCtrl Grid to Work

The DBCtrlGrid is an esoteric component rife with possibilities, so any minor demonstration is going to seem insignificant. While this is certainly true, the ticket sales demo will, at the very least. give you an idea of how the component works so that you might consider it as a solution to your next design. The application that we are going to build is the last piece we will construct for the Venue Manager application. The program written here is a stand-alone application meant to run on a ticket kiosk with a touch screen where the purchasers can scroll through the events scheduled and then press the bar that represents the event to order tickets.

Start a new application and add a DBNavigator and a DBCtrlGrid to the form. Set the Align property for the navigator to alBottom and the same property of the control grid to alClient. The form should be nicely filled with both of these components now. Save your project.

Add two Table components and a DataSource component to the form. Tablel should have the DatabaseName property set to DBDEMOS and the TableName property set to EVENTS.DB. Table2 will have the same database name and the TableName property set to VENUES.DB. Point the DataSource component to Tablel.

Key Code

Figure 6. 16 The Tickets moiri form

Figure 6. 16 The Tickets moiri form

Chapter 6—Delphi's Data-Aware Components || 2071

Set the DataSource property of the navigator to DataSourcelJ The DBCtrlGridl is a panel-based container control. When the DataSourcel property is set to DataSourcelJ this becomes the DataSource property for all of the child components and cannot be modified.

We need a little information from the VENUES table so a lookup field will be created. Select Table 1 and invoke the Fields Editor. Add all of the existing fields and then click on New Field from the context menu. Name the new field Venue, set the Type property to String, and make the length 25. Be sure to check the Lookup radio button to access the rest of the properties. The DataSer property will be Table2j the Key and Lookup fields will be VenueNo, and the Result field will be Venue. This will return the name of the venue so that it can be displayed on each panel.

Have a look at Figure 6.16 to see how the remaining components are going to be laid out.

The top panel of the grid is the one on which all of your layout should occur so that the desired behavior of the control grid is retained. The striped panels represent the placement of the other rows of the database and are shown for your design reference.

As shown, add the appropriate components to the top panel of the grid. There are some limitations to the DBCtrlGrid; foremost, the following components cannot be used on the grid:

Part /i-The Delphi Database Tools

Was this article helpful?

0 0

Post a comment