Subject Re: [IBO] IB_Grid, pressing enter at last column
Author Helen Borrie
At 07:25 PM 2/03/2006, you wrote:
>(Using ibo 4.5b)
>
>When I am at the last column of an ib_grid and press Enter key while
>the row is in dssedit state, the underlying dataset is posted and
>attempts to move to the next row.

Yes.

>In the beforepost event of the
>connected ib_query, i check for some conditions and abort if necessary.

By that, do you mean that you call Sysutils.Abort?

>I observed that aborting at the beforepost event produces undesirable
>results (eg, form closed for no apparent reason),

Abort is definitely nothing like a Dataset.Cancel. If indeed you
call Abort, then what happens is that Delphi throws a silent
exception and redirects execution to the end of the last try ..
finally block in the execution path. If the form is modal, then of
course that will close the form. If the form isn't modal, then
execution will go to the end of the execution path and do the default
Enter key action, e.g. click the Close button or whatever you have.

If you just want to cancel the editing action and intervene with some
message to the user, call the dataset's Cancel method.

>although the row
>remains in dssedit state. NOTE, however, that this does not happen if I
>simply press UP or DOWN key, only when i use the enter key.

If the current row has any modified fields then pressing the up or
down key will cause the Post event to fire; but not otherwise. If
Abort gets called (due to changes in the row) then the BeforePost
will be visited and your Abort call will happen. However, the
execution path for an up or down key press is never going to end up
with closing a form since they are incapable of that. Enter will do
it if there is no trap for it.


>What am I doing wrong. Please help. TIA

Don't know for sure. If you're intervening in the BeforePost in
order to prevent an invalid entry from making it to the database,
then you should call Dataset.Cancel and throw an exception that you
can catch and handle.

Helen