Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to hide the scrollbars of a DBGrid

Title: How to hide the scrollbars of a DBGrid type TNoScrollDBGrid = class(TDBGrid) private procedure WMNCCalcSize(var Msg: TMessage); message WM_NCCALCSIZE; end; procedure TNoScrollDBGrid.WMNCCalcSize(var Msg: TMessage); const Scrollstyles = WS_VSCROLL or WS_HSCROLL; var Style: Integer; begin Style := GetWindowLong(Handle, GWL_STYLE); if (Style and Scrollstyles) 0 then SetWindowLong(Handle, GWL_STYLE, Style and not Scrollstyles); inherited; end; //This removes both scrollbars. If you want to remove only the vertical one //change the scrollstyles constant accordingly.