Delphi: How to select row in a TDBGrid after deleting a record?
I'm running a SQL query to delete the record, then trying the following:
gridProjects.DataSource.DataSet.DisableControls;
try
gridProjects.DataSource.DataSet.Refresh;
finally
gridProjects.DataSource.DataSet.EnableControls;
end;
The record disappears from the grid, but then the user cannot select another row in the grid, using the mouse or keyboard, and no row in the grid is highlighted. It acts as if it's lo开发者_开发知识库cked up.
Try moving the call to DisableControls
to inside the try/finally
block. If that "solves" the immediate issue, stop everything and go find out what is throwing an exception in DisableControls
.
精彩评论