jahlxx Posted October 5, 2016 Posted October 5, 2016 hi. whe a dbgrid is paged, with arrow keys I move to next and / or prior record. with down arrow key, when the cirsor is in nthe last record of one page, how can I do to go to next record (first record of next page? Now the corsor stops in the last record and have to move to next page manually. Thanks. Quote
Sherzod Posted October 5, 2016 Posted October 5, 2016 Hi, Can you try this approach ?!: For example for "down": procedure TMainForm.UniDBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key = VK_DOWN)and((Sender as TUniDBGrid).WebOptions.Paged) then begin if ((Sender as TUniDBGrid).DataSource.DataSet.RecNo mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0 then (Sender as TUniDBGrid).DataSource.DataSet.Next end; end; You should also think about the logic of "up"... Best regards. 1 Quote
jahlxx Posted July 24, 2017 Author Posted July 24, 2017 I have this: for up key, this works, but have a extrange behaviour if (Key = VK_UP)and((Sender as TUniDBGrid).WebOptions.Paged) then begin if ((Sender as TUniDBGrid).DataSource.DataSet.RecNo mod (Sender as TUniDBGrid).WebOptions.PageSize) <> 0 then (Sender as TUniDBGrid).DataSource.DataSet.Prior end; And with this don't work: if (Key = VK_UP)and((Sender as TUniDBGrid).WebOptions.Paged) then begin if ((Sender as TUniDBGrid).DataSource.DataSet.RecNo-1 mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0 then (Sender as TUniDBGrid).DataSource.DataSet.Prior end; ?????? Quote
Sherzod Posted July 24, 2017 Posted July 24, 2017 Hi, Try: if (Key = VK_DOWN)and((Sender as TUniDBGrid).WebOptions.Paged) then begin if ((Sender as TUniDBGrid).DataSource.DataSet.RecNo mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0 then (Sender as TUniDBGrid).DataSource.DataSet.Next end else if (Key = VK_UP)and((Sender as TUniDBGrid).WebOptions.Paged) then begin Caption := IntToStr((Sender as TUniDBGrid).DataSource.DataSet.RecNo); if (((Sender as TUniDBGrid).DataSource.DataSet.RecNo-1) mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0 then (Sender as TUniDBGrid).DataSource.DataSet.Prior end; Best regards, Quote
jahlxx Posted July 24, 2017 Author Posted July 24, 2017 oops. parenthesis. starter mistake!!! thanks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.