community.borland.com

Article #15874: Removing the vertical scrollbar from a TDBGrid

 Technical Information Database

TI874D.txt   Removing the vertical scrollbar from a TDBGrid
Category   :Database Programming
Platform    :All
Product    :Delphi  All

Description:
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.


Reference:


7/16/98 4:33:56 PM
 

Last Modified: 01-SEP-99