Jump to content

Data cursor moving to first row by itself


wsv01

Recommended Posts

I am having this specific problem when trying to remove a row of data from an open cursor. When using this type of syntax attached to a button:

MessageDlg('Are you sure you want to delete this record? ', mtConfirmation, mbYesNo, RemoveDocCallback); 

Then running a callback procedure like this with no code or code in it, the data cursor moves to the 1st row of data by itself.

procedure TfrmViewUploads.RemoveDocCallback(Sender: TComponent; Res: Integer);
begin

end;

Let's say there are 3 rows of data in a uniDBGrid shown and I select the 2nd row, then click a button that asks a MessageDlg like above. When Yes is selected, the cursor will move to the 1st row of data by itself. I am using FireDac and connecting to a MSSQL database and pulling data into the cursor via a stored procedure call. If anyone can duplicate this or tell me what I an doing wrong, that would be great. 


 

Link to comment
Share on other sites

A quick update.  I think this has something to do with the callback to the window I have the data in. If I simply drag the window a little in either direction, the cursor is refreshed and pointed to the 1st row. I know it's something I do not understand with a window refreshing while there is an open data set in a grid. 

Link to comment
Share on other sites

It does not matter how many rows there are. In my own stupidity, I found the issue. On the form OnActivate event I called a procedure that opens the data set.  When a form is simply dragged in any direction, it fires off the OnActivate event. Originally I thought it was something to do with the call back, but it really has to do with the form refreshing. I moved the procedure that opens the data set to the OnSHow event and all is well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...