External scrollbars in FNCDataGrid

I’m building a spreadsheet-like UI so at the bottom of the grid I need worksheet tabs and the horizontal scrollbar to the right of them. At the moment I set CustomScrollbars = true, but I hide them and then create another FNCScrollbar in the required layout. I then just sync the external scrollbars with the hidden scrollbars. This works but is a bit kludgy - would it be possible to have the option of linking the grid to externally-defined scrollbars? This would also allow other scrollbar implementations to be used besides the FNCScrollbar.

Thanks, Bob

Hi,

This is a good idea, we’ll provide an interface, which can be connected to a scrollbar (you’ll need to write a custom implementation), and then connect it to the grid.

It will look something like this:

unit Unit13;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.TMSFNCTypes, FMX.TMSFNCUtils, FMX.TMSFNCGraphics, FMX.TMSFNCGraphicsTypes,
  System.Rtti, FMX.TMSFNCDataGridCell, FMX.TMSFNCDataGridData,
  FMX.TMSFNCDataGridBase, FMX.TMSFNCDataGridCore, FMX.TMSFNCDataGridRenderer,
  FMX.TMSFNCCustomControl, FMX.TMSFNCDataGrid, FMX.StdCtrls;

type
  TScrollBarEx = class(TScrollBar, ITMSFNCDataGridExternalScrollBar)
  public
    function GetValue: Double;
    procedure SetValue(const AValue: Double);
    function GetMin: Double;
    procedure SetMin(const AValue: Double);
    function GetMax: Double;
    procedure SetMax(const AValue: Double);
    function GetPageSize: Double;
    procedure SetPageSize(const AValue: Double);
    function GetSmallChange: Double;
    procedure SetSmallChange(const AValue: Double);
    function GetLargeChange: Double;
    procedure SetLargeChange(const AValue: Double);
    function GetIsVisible: Boolean;
    procedure SetIsVisible(const AValue: Boolean);
    function GetOnChange: TNotifyEvent;
    procedure SetOnChange(const AValue: TNotifyEvent);
    property Value: Double read GetValue write SetValue;
    property Min: Double read GetMin write SetMin;
    property Max: Double read GetMax write SetMax;
    property PageSize: Double read GetPageSize write SetPageSize;
    property SmallChange: Double read GetSmallChange write SetSmallChange;
    property LargeChange: Double read GetLargeChange write SetLargeChange;
    property Visible: Boolean read GetIsVisible write SetIsVisible;
    property OnChange: TNotifyEvent read GetOnChange write SetOnChange;
  end;

  TForm13 = class(TForm)
    TMSFNCDataGrid1: TTMSFNCDataGrid;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form13: TForm13;

implementation

{$R *.fmx}

procedure TForm13.FormCreate(Sender: TObject);
var
  sb: TScrollBarEx;
begin
  sb := TScrollBarEx.Create(Self);
  sb.Parent := Self;
  sb.Align := TAlignLayout.Right;
  sb.Orientation := TOrientation.Vertical;
  sb.Width := 20;
  TMSFNCDataGrid1.ExternalVerticalScrollBar := sb;
end;

{ TScrollBarEx }

function TScrollBarEx.GetLargeChange: Double;
begin
  Result := 0;
end;

function TScrollBarEx.GetMax: Double;
begin
  Result := inherited Max;
end;

function TScrollBarEx.GetMin: Double;
begin
  Result := inherited Min;
end;

function TScrollBarEx.GetOnChange: TNotifyEvent;
begin
  Result := inherited OnChange;
end;

function TScrollBarEx.GetPageSize: Double;
begin
  Result := inherited ViewportSize;
end;

function TScrollBarEx.GetSmallChange: Double;
begin
  Result := inherited SmallChange;
end;

function TScrollBarEx.GetValue: Double;
begin
  Result := inherited Value;
end;

function TScrollBarEx.GetIsVisible: Boolean;
begin
  Result := inherited Visible;
end;

procedure TScrollBarEx.SetLargeChange(const AValue: Double);
begin
end;

procedure TScrollBarEx.SetMax(const AValue: Double);
begin
  inherited Max := AValue;
end;

procedure TScrollBarEx.SetMin(const AValue: Double);
begin
  inherited Min := AValue;
end;

procedure TScrollBarEx.SetOnChange(const AValue: TNotifyEvent);
begin
  inherited OnChange := AValue;
end;

procedure TScrollBarEx.SetPageSize(const AValue: Double);
begin
  inherited ViewportSize := AValue;
end;

procedure TScrollBarEx.SetSmallChange(const AValue: Double);
begin
  inherited SmallChange := AValue;
end;

procedure TScrollBarEx.SetValue(const AValue: Double);
begin
  inherited Value := AValue;
end;

procedure TScrollBarEx.SetIsVisible(const AValue: Boolean);
begin
  inherited Visible := AValue;
end;

end.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.