H
Haim Katz
I have a winform with a datagrid bound to a dataview with the allowDelete
property set to false.
The datagrid is readonly. When the user enters the datagrid and presses the
delete key the row is not deleted, but the currentrowindex is changed to -1.
When the grid looses focus I get an error "Error when committing the row to
the original data store, row index is negative...". I've tried to trap this
error in the datagrid's validating, keydown, lostfocus events with the
following code:
IF datagrid1.currentrowindexs<0 then datagrid1.currentrowindex = 0
The event is fired and the code is run, but the datagrid ignores my
instructions and the index remains at -1.
Ive tried using a derived grid overiding the PreprocessMessage function
with
.....
if msg.msg = wm_keydown and keycode = keys.delete then
return true
End if
This also fires but does not prevent the error.
Can anyone help me get my respect back and have the datagrid do what I want?
Haim
property set to false.
The datagrid is readonly. When the user enters the datagrid and presses the
delete key the row is not deleted, but the currentrowindex is changed to -1.
When the grid looses focus I get an error "Error when committing the row to
the original data store, row index is negative...". I've tried to trap this
error in the datagrid's validating, keydown, lostfocus events with the
following code:
IF datagrid1.currentrowindexs<0 then datagrid1.currentrowindex = 0
The event is fired and the code is run, but the datagrid ignores my
instructions and the index remains at -1.
Ive tried using a derived grid overiding the PreprocessMessage function
with
.....
if msg.msg = wm_keydown and keycode = keys.delete then
return true
End if
This also fires but does not prevent the error.
Can anyone help me get my respect back and have the datagrid do what I want?
Haim