Board index » delphi » How to disable scrolling in a TStringGrid

How to disable scrolling in a TStringGrid

I need to disable the scrolling feature in a TStringGrid when selecting a
cell which is partially outside the right edge of the grid. How could I do
that? Alternatively I need a way to scroll the THeaderSection I use with the
TStringGrid. Any ideas?

Regards
Johan

 

Re:How to disable scrolling in a TStringGrid


I do this kind of thing by disabling messages.  For example,

Type
TMyStringGrid = Class(TStringGrid)
Protected
    procedure vscroll(Var NewMessage: TMessage); message wm_vscroll;
  end;

Var
  NewGrid: TMyStringGrid;

procedure TMyStringGrid.vscroll(Var NewMessage: TMessage);

Var Goodthingshappen: Boolean;
begin
 {lots of lines to determine if everything is nice}
  If Goodthingshappen then  inherited;
end;

{and obviously somewhere in yur code you need lines such as
  NewGrid := TMyStringGrid.create(self);
  NewGrid.Free;
 etc....

This code will just throw away a vertical scroll message anytime that
good things don't happen.

Regards - Brian

Quote
Johan Arthursson wrote:
> I need to disable the scrolling feature in a TStringGrid when selecting a
> cell which is partially outside the right edge of the grid. How could I do
> that? Alternatively I need a way to scroll the THeaderSection I use with the
> TStringGrid. Any ideas?

> Regards
> Johan

Other Threads