Jump to content

dbgrid scroll


jahlxx

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...