How a DataWindowControl manages data

As users add or change data, the data is first handled as text in an edit control. If the data is accepted, it is then stored as an item in a buffer.

About the DataWindow buffers

A DataWindow uses three buffers to store data:

Table 3-1: DataWindow buffers

Buffer

Contents

Primary

Data that has not been deleted or filtered out (that is, the rows that are viewable)

Filter

Data that was filtered out

Delete

Data that was deleted by the user or through code

About the edit control

As the user moves around the DataWindowControl, the DataWindow places a temporary edit control over the current cell (row and column). The edit control displays as a dotted rectangle.

The edit control is treated by Windows as a separate control that floats on the DataWindowControl. As a result, MouseEnter and MouseLeave events are fired as the cursor moves over each cell. The contents of the edit control are text data that has not yet been accepted by the DataWindowControl. Data entered in the edit control is not in a DataWindow buffer yet; it is simply text in the edit control.

About items

When the user changes the contents of the edit control and presses Enter or leaves the cell (by tabbing or pressing Up arrow or Down arrow from the keyboard), the DataWindow processes the data and either accepts or rejects it, depending on whether it meets the requirements specified for the column.

If the data is accepted, the text is moved to the current row and column in the DataWindow Primary buffer. The data in the Primary buffer for a particular column is referred to as an item.

Events for changing text and items

When data is changed in the edit control, several events occur.

Table 3-2: Events triggered by changing text and items

Event

Description

DataWindowKeyDown

Occurs when a key is pressed in the edit control

EditChanged

Occurs for each keystroke the user types in the edit control

ItemChanged

Occurs when a cell has been modified and loses focus

ItemError

Occurs when new data fails the validation rules for the column

ItemFocusChanged

Occurs when the current item in the DataWindowControl changes

How text is processed in the edit control

When the data in a column in a DataWindow has been changed and the column loses focus (for example, because the user tabs to the next column), the following sequence of events occurs:

  1. The DataWindowControl converts the text into the correct datatype for the column. For example, if the cursor is in a numeric column, the DataWindowControl converts the string that was entered into a number. If the data cannot be converted, the ItemError event is triggered.

  2. If the data converts successfully to the correct datatype, the DataWindowControl applies any validation rule used by the column. If the data fails validation, the ItemError event is triggered.

  3. If the data passes validation, the ItemChanged event is triggered.

  4. If the ItemChanged event accepts the data, the ItemFocusChanged event is triggered and the data is stored as an item in the Primary buffer.