Using DataWindows for Windows Forms
The process to integrate the DataWindow into your .NET application is very simple. Once you understand a few of the key properties of the Transaction object and the DataWindow control, using them is just as simple as using .NET's native controls.
As stated in the overview, the first step is to connect to the database by adding a non-visual transaction object from the toolbox. You can then drag a DataWindowControl from the toolbox to the form. Figure 10
shows the control prior to setting any properties. Setting two properties provides a link to the DataWindow object you created via the DataWindow designer. Setting the LibraryList
properties immediately shows a sample outline from your data source, but does not show actual data (see Figure 11
). The immediate view provides a nice way to lay out your data and forms.
|Figure 10. An Empty DataWindow Control: Here's how a DataWindow control looks at runtime before you set any of its properties.||
|Figure 11. Immediate View: Although the immediate view doesn't display actual data, it does provide a convenient way to lay out controls on your forms.||
As discussed earlier, the following three lines of code allowed the form to connect to the database and retrieve data:
To save data back to the database requires two additional lines of code:
The properties and events available for the DataWindow control are expansive. Figure 12
shows the final window running in a Windows Forms application. One nice feature is the drop-down calendar for dates. You configure this component by setting a DataWindow property in the designer. The drop-down calendar works in both Windows Forms and Web Forms applications.
|Figure 12. Live DataWindow: The figure shows a configured DataWindow at runtime, with live data. Developers can add features such as the drop-down calendar with no coding, by simply setting DataWindow properties.||
|Figure 13. A TreeView Report: This Windows Forms-only report type provides an expandable hierarchical tree view of the report data.||
A new DataWindow type available for Windows forms only is a Treeview report. Using the same Wizard-like interface to select the report type (TreeView), data source and query simplifies creating complex data-driven tree views (see Figure 13
). The only coding required is the few lines to retrieve the data.