Mega Code Archive

 
Categories / Delphi / ADO Database
 

Removing the Vertical Scroll Bar from a TDBGrid

Title: Removing the Vertical Scroll Bar from a TDBGrid Question: How to remove the vertical scrollbar from a dbgrid ? Answer: 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 TNoScrollBarDBGrid that does this. type TNoScrollBarDBGrid = class(TDBGrid) private protected procedure Paint; override; public published end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TNoScrollBarDBGrid]); end; { TNoScrollBarDBGrid } procedure TNoScrollBarDBGrid.Paint; begin SetScrollRange(Handle, SB_VERT, 0, 0, false); inherited; end;