morgantop
asked on
how to keep dbgrid in edit mode only?
hi,
i would like to prevent users from inserting or deleting (ctrl + del) data in a TDBGrid.
please help.
i would like to prevent users from inserting or deleting (ctrl + del) data in a TDBGrid.
please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
easiest way is to place abort; in your Table/Query BeforeDelete and BeforeInsert events.
procedure Table1BeforeInsert(DataSet : TDataSet);
begin
// yoy can optionally check for some flag if you need append/delete record in program
// if UserEditMode then
abort;
end;
to prevent for Delete/Insert only within Grid you must catch pressed keys in OnKeyDown event and that is more complex as, for example, TAB key produces row insertion if it is pressed on last editable column in last row etc.
wbr, mo.
procedure Table1BeforeInsert(DataSet
begin
// yoy can optionally check for some flag if you need append/delete record in program
// if UserEditMode then
abort;
end;
to prevent for Delete/Insert only within Grid you must catch pressed keys in OnKeyDown event and that is more complex as, for example, TAB key produces row insertion if it is pressed on last editable column in last row etc.
wbr, mo.
ASKER
thanks kretzschmar,
you did it again.
mo, thanks also but he was too fast ;)
you did it again.
mo, thanks also but he was too fast ;)
yee, 3 min late :D
I saw your question 1h before, but I had to go to English courses, to polish my writing speed and style :)
good luck!
mo.
I saw your question 1h before, but I had to go to English courses, to polish my writing speed and style :)
good luck!
mo.
you must disable the dgConfirmDelete in the dbgrid.option
to get rid of the ConfirmDeleteMessageBox
meikl ;-)