Data Access Modes > User Events Mode |
Setting the DataMode property to 2 - User Events causes a TData control to function in user event mode.
User events mode is provided for advanced users who need to create their own custom data source. In this mode, the programmer has full control over the data and specifies the behavior of the custom data source by writing Visual Basic code to handle special True DataControl events: UserReadData, UserWriteData, UserAddData, UserDeleteRow, and UserFindData. These events work as follows:
When the form is loaded, bound controls request data from True DataControl for display. As the user navigates the data source with the bound controls, they continue to request additional data from True DataControl. In turn, True DataControl requests data from the application by firing the UserReadData event. A special object, RowBuffer, is used in the UserReadData event to receive the data values and bookmarks for the rows returned by the event handler.
The user may also modify, add, or delete data using bound controls. The bound controls notify True DataControl of all such data changes. In turn, True DataControl fires the UserWriteData, UserAddData, or UserDeleteRow events, which notify the application that the data source should be updated accordingly. The RowBuffer object and bookmarks are used in these events to communicate information about individual rows.
If you are familiar with ComonentOne True DBGrid unbound mode, you will find the True DataControl user events mode easy to understand. It uses the same events, although True DataControl calls them ‘User’ instead of the grid’s "Unbound." There are some slight differences in writing code for True DataControl's user events mode and True DB Grid's unbound mode, see True DataControl user event mode and True DBGrid unbound mode.
Note: User events mode is unavailable in True DataControl Lite. |