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.

有帮助吗?

解决方案

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.

其他提示

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top