Jump to content

dbgrid scroll


jahlxx
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

  • 9 months later...

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;

 

 

 

??????

Link to comment
Share on other sites

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,

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.

 Share

×
×
  • Create New...