AdvDBGrid and page scrolling

Hi


There is a code to implement a page scrolling of a grid ? i want to make it with 2 buttons 'Up' and 'Down' 

Thank u

Programmatic scroll in the grid is done by using the grid.TopRow: integer property to set the scroll position.

Hi i've implemented page scrolling like this, but i've problem of recno moving ...
Can u help me ?

procedure TForm1.FormCreate(Sender: TObject);
begin
  for i:=0 To 40 Do
    mmArt.AppendRecord([Inttostr(i),Inttostr(i)]);

  mmArt.First;

  grdArt.DataSetType:=dtNonSequenced;

  vrc:=grdArt.VisibleRowCount;
  Tr:=0;
  grdArt.TopRow:=Tr;
end;
// -----------------------------------------------------------------------------
procedure TForm1.btUpClick(Sender: TObject);
begin
  grdArt.BeginUpdate();

  Dec(Tr,vrc);

  If Tr < 0 Then Tr:=0;
  grdArt.TopRow:=Tr;

  grdArt.EndUpdate();
end;
// -----------------------------------------------------------------------------
procedure TForm1.btDownClick(Sender: TObject);
begin
  grdArt.BeginUpdate();

  Inc(Tr,vrc);
  grdArt.TopRow:=Tr;

  grdArt.EndUpdate();
end;

I want to say one thing : i think page scrolling for a grid is very important. Why do u not implemented this features ?

Bye

I do not understand what you mean with:


"I've problem of recno moving"?

What exactly do you mean with this?

excuse me i supplied code above. grdArt.TopRow dont move cursor at begin of grid ... i must do something else ?

You can move to a specific row with property:

Grid.Row: integer; 

Grid.Row := idx;

 

In case the row is not visible, you have to programmatically set the scroll position with

 

Grid.TopRow: integer;

For example i must scroll grid for a page of 8 rows then i set Row = 8, 8x2, 8x3 and toprow ?

Is this a DBAdvGrid  with PageMode = true or false?
If DBAdvGrid.PageMode = true, an alternative is to use:


dataset.MoveBy(8);
dataset.MoveBy(2*8);
etc..

OK but the problem is to put records in the exact position : if i have 40 recs and 10 per page i could have 1 page recs 1 to 10 (first row on the grid = 1), press page down -> 2 page recs 11 to 20 (first row on the grid = 11), press page down ->  3 page recs 21 to 30 (first row on the grid = 21), and so on ...

NOTE IF grdArt.dtNonSequenced and PageMode = True

  grdArt.BeginUpdate();
  showmessage(  inttostr( grdArt.TopRow ));
  showmessage(  inttostr(  grdArt.GetTopRowEx ));
  grdArt.EndUpdate();

grdArt.TopRow has always same value NOT indicate recno of first rec in a grid !!


There is a dependency on the way the dataset does the buffering of records. This is something at dataset level.
If you do not want this dataset buffer size interfering and precise control over scroll position, set DBAdvGrid.PageMode = false and then you can use DBAdvGrid.TopRow