This section describes how to create a DataWindow object by calling the Create method in an application.
DataWindow painter You should use the techniques described here for creating a DataWindow from syntax only if you cannot accomplish what you need to in the DataWindow painter. The usual way of creating DataWindow objects is to use the DataWindow painter.
To learn about creating DataWindow objects in the DataWindow painter, see the User's Guide.
You use the Create method to create a DataWindow object dynamically at runtime. Create generates a DataWindow object using source code that you specify. It replaces the DataWindow object currently in the specified DataWindow control with the new DataWindow object.
Resetting the transaction object The Create method destroys the association between the DataWindow control and the transaction object. As a result, you need to reset the control's transaction object by calling the SetTransObject or SetTrans method after you call Create.
To learn how to associate a DataWindow control with a transaction object, see Chapter 9, “Using DataWindow Objects.”
There are several ways to specify or generate the syntax required for the Create method:
Use the SyntaxFromSQL method of the transaction object
Use the DataWindow.Syntax property of the DataWindow object
Create the syntax yourself
Using SyntaxFromSQL You are likely to use SyntaxFromSQL to create the syntax for most dynamic DataWindow objects. If you use SyntaxFromSQL, all you have to do is provide the SELECT statement and the presentation style.
In PocketBuilder, SyntaxFromSQL is a method of the transaction object. The transaction object must be connected when you call the method.
SyntaxFromSQL has three required arguments:
A string containing the SELECT statement for the DataWindow object
A string identifying the presentation style and other settings
The name of a string you want to fill with any error messages that might be returned
SyntaxFromSQL returns the complete syntax for a DataWindow object that is built using the specified SELECT statement.
Using the DataWindow.Syntax property You can obtain the source code of an existing DataWindow object to use as a model or for making minor changes to the syntax. Many values in the source code syntax correspond to properties of the DataWindow object.
This example gets the syntax of the DataWindow object in the DataWindow control, dw_1, and displays it in the text box control, textb_dw_syntax:
var dwSyntax
dwSyntax = dw_1.Describe("datawindow.syntax") textb_dw_syntax.value = dwSyntax
Creating the syntax yourself You need to create the syntax yourself to use some of the advanced dynamic DataWindow features, such as creating a group break.
The DataWindow source code syntax that you need to supply to the Create method can be very complex. To see examples of DataWindow object syntax, go to the Library painter and export a DataWindow object to a text file, then view the file in a text editor.
For more information on Create and Describe methods, as well as DataWindow object properties and syntax, see the DataWindow Reference in the online Help.