Subject | Re: [IBO] IB_Grid, pressing enter at last column |
---|---|
Author | Helen Borrie |
Post date | 2006-03-02T10:20:06Z |
At 07:25 PM 2/03/2006, you wrote:
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.
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.
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
>(Using ibo 4.5b)Yes.
>
>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.
>In the beforepost event of theBy that, do you mean that you call Sysutils.Abort?
>connected ib_query, i check for some conditions and abort if necessary.
>I observed that aborting at the beforepost event produces undesirableAbort is definitely nothing like a Dataset.Cancel. If indeed you
>results (eg, form closed for no apparent reason),
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 rowIf the current row has any modified fields then pressing the up or
>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.
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. TIADon'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