For our dbgrid we want the scrollbars to be constantly hidden.
Since TDBGrid doesn’t have a ‘scrollbars’ property, we use:
ShowScrollBar(DBGrid1.Handle, SB_VERT, False);
ShowScrollBar(DBGrid1.Handle, SB_HORZ, False);
However when we resize the window (and the panel containing the dbgrid), for
a second the scrollbars appear and becom hidden again only after recalling
the two above methods.
A solution is to call these methods in DrawColumnCell, but this causes flickering
of the dbgrid, even with DoubleBuffered set to true.
Is there any way to hide the scrollbars permanently?
Thanks in advance!
Hiding the scrollbar of the
TDBGridinCreateParamshas a very short time effect. There’s the procedureUpdateScrollBarwhich causes the scrollbar to be visible. It happens because the scroll bar visibility is controlled depending on the data displayed, thus this procedure is called whenever the data is changed.And since this procedure is called whenever the scrollbar needs to be updated and because it’s virtual, it’s time to override it.
The following code sample uses the interposed class, so all
TDBGridcomponents on the form which belongs to this unit will behave the same: