Pregunta

How i can hide or remove scrolling by horizontal on dbgrid in Delphi7. I have try by changing width onResize but its not correctly way.

¿Fue útil?

Solución

Try this:

EnableScrollBar(DBGrid1.Handle,SB_HORZ,ESB_DISABLE_BOTH);
ShowScrollBar(DBGrid1.Handle,SB_HORZ,False);

The problem is that disables the scroll, but it displays :-(

Other option is:

TDBgrid2 = class(TDBgrid)
  private
    procedure WMNCCalcSize(var msg: TMessage); message WM_NCCALCSIZE;
  end;
  .
  .
procedure TDBgrid2.WMNCCalcSize(var msg: TMessage);
var
  style: Integer;
begin
  style := getWindowLong( handle, GWL_STYLE );
  if (style and WS_HSCROLL) <> 0 then
    SetWindowLong( handle, GWL_STYLE, style and not WS_HSCROLL );
  inherited;
end;

It is more complicated, but it is the perfect solution.

Otros consejos

A followup to the David's perfect solution. You don't have to change the class in .dfm if using same type names

  TDBgrid = class(DBGrids.TDBgrid)
  private
    procedure WMNCCalcSize(var msg: TMessage); message WM_NCCALCSIZE;
  end;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top