TAdvStringGrid
Example 79 : Adding scrollbars on grid cells

This is an overview of the methods available:
grid.AddScrollbar(col,row: integer; AutoRange: boolean); | Adds a scrollbar to cell col,row and when AutoRange is true, the scrollbar range and pagesize is automatically calculated. |
grid.RemoveScrollbar(col,row: integer); | Removes the scrollbar again from the cell |
grid.HasScrollBar(col,row: integer): boolean | Returns true when the cell col,row has a scrollbar |
grid.HasAutoRangeScrollBar(col,row: integer): boolean | Returns true when the cell col,row has an autorange scrollbar |
grid.SetScrollPosition(col,row,position: integer); | Programmatically sets the position of the scrollbar in cell col,row |
grid.GetScrollPosition(col,row,position: integer): integer; | Programmatically gets the position of the scrollbar in cell col,row |
grid.SetScrollProp(col,row: integer; Prop: TScrollProp); | Sets the scrollbar range & pagesize |
grid.GetScrollProp(col,row: integer): TScrollProp; | Gets the scrollbar range & pagesize |
Delphi project & source files for downloading included in the main demos distribution for Delphi
In the sample, these capabilities are demonstrated by adding very long HTML formatted text in 3 cells of the grid. In these cells, first an autorange scrollbar was added with:
advstringgrid1.AddScrollBar(2,1,true); advstringgrid1.AddScrollBar(2,2,true); advstringgrid1.AddScrollBar(2,3,true);
procedure TForm2.AdvStringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); var sp: TScrollProp; begin if AdvStringgrid1.HasScrollBar(Acol,ARow) then begin sp := AdvStringgrid1.GetScrollProp(ACol,ARow); updown1.Min := 0; updown1.Max := sp.Range; updown1.Position := sp.Range - AdvStringgrid1.GetScrollPosition(ACol,ARow); end; end; procedure TForm2.UpDown1Changing(Sender: TObject; var AllowChange: Boolean); var sp: TScrollProp; begin if AdvStringGrid1.HasScrollBar(AdvStringgrid1.Col, AdvStringGrid1.Row) then begin AdvStringGrid1.SetScrollPosition(AdvStringgrid1.Col, AdvStringGrid1.Row, updown1.Max - updown1.Position); end; end;
Delphi project & source files for downloading included in the main demos distribution for Delphi
×