>I have a DBGrid which always displays a vertical scroll bar even when
it is
>not needed. Is there anyway to remove it, and only display it
when needed?
Here is an entry from the DTOPICS help file.
--------------------------------------------
Removing the vertical scrollbar from a TDBGrid
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.