Object Reference > True DBGrid Methods > PostMsg Method |
PostMsg Method
The PostMsg method is used in conjunction with the PostEvent event to postpone operations which are illegal within the grid's events.
object.PostMsg MsgId
Arguments
MsgId is an integer that identifies the message being posted.
Return Value
None
If the PostMsg method is called, the grid will fire the PostEvent event with the MsgId of the corresponding PostMsg invocation after all pending operations are completed. You can then safely perform all desired operations in the PostEvent event.
For example, it is not possible to perform the Data control's Refresh method within the grid's AfterUpdate event because database operations are still pending, and the refresh cannot be tolerated. Instead of performing the refresh in the AfterUpdate event, you can call the PostMsg method (with a MsgId value of 1, for instance). After all pending database operations are completed, the grid will fire the PostEvent event. You can then perform the refresh operation safely in this event, after confirming that the MsgId argument passed in is 1.
You can use any non-zero integral value for MsgId, which will be passed to the PostEvent event for identification purposes.
The special case where MsgId is zero is used to clear any pending PostMsg invocations which have not yet been processed. A PostEvent event will fire for this case.
Note
Take care to avoid recursive situations when using PostMsg and PostEvent.