- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


2840:Removing the vertical scrollbar from a TDBGrid

KEYWORDS: dbgrid grid scrollbar vertical vscroll AREA: Database Programming

In order to remove the vertical scrollbar from a TDBGrid component,
you must override its Paint method.  Inside the Paint method you
must call the SetScrollRange API procedure to set the min and max
scroll values to zero (this disables the scrollbar), and then call
the inherited Paint.  The code below is a unit containing a new
component called TNoVertScrollDBGrid that does this.  You can copy
the code into a file called NEWGRID.PAS, and add it to the component
library as a custom component.


unit Newgrid;

interface

uses
  WinTypes, WinProcs, Classes, DBGrids;

type
  TNoVertScrollDBGrid = class(TDBGrid)
  protected
    procedure Paint; override;
  end;

procedure Register;

implementation

procedure TNoVertScrollDBGrid.Paint;
begin
  SetScrollRange(Self.Handle, SB_VERT, 0, 0, False);
  inherited Paint;
end;

procedure Register;
begin
  RegisterComponents('Data Controls', [TNoVertScrollDBGrid]);
end;

end.

        TI



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile