Board index » delphi » Disabling horizontal scrolling in TStringGrid

Disabling horizontal scrolling in TStringGrid

How do I disable the horizontal scrolling in a TStringGrid. Hiding the
horizontal scrollbar is not enough because selecting the rightmost cell
might trigger a scroll event if the cell is larger than the remaining
TStringGrid.

Regards
Johan

 

Re:Disabling horizontal scrolling in TStringGrid


Hallo Johan,
Try so (not tested):
type
  THackGrid = class (TCustomGrid)
public
  property ScrollBars;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
  THackGrid(StringGrid1).ScrollBars := ssVertical;
end;
--
Kind regards,
Andrei Fomine, Altive Software Ltd., i...@dbaltgrid.com
DbAltGrid allows a free-form layout and hierarchical columns structure in a
DBGrid descendant. http://www.dbaltgrid.com

Quote
Johan Arthursson <SendAnswerToNewsGroup> wrote in message

news:87lsip$7ol10@bornews.borland.com...
Quote

> How do I disable the horizontal scrolling in a TStringGrid. Hiding the
> horizontal scrollbar is not enough because selecting the rightmost cell
> might trigger a scroll event if the cell is larger than the remaining
> TStringGrid.

> Regards
> Johan

Re:Disabling horizontal scrolling in TStringGrid


Try enlarging the parent form or narrowing the string grid so that the last
column is just within the border of the parent.

Best wishes

Quote
Johan Arthursson wrote:
> How do I disable the horizontal scrolling in a TStringGrid. Hiding the
> horizontal scrollbar is not enough because selecting the rightmost cell
> might trigger a scroll event if the cell is larger than the remaining
> TStringGrid.

> Regards
> Johan

Re:Disabling horizontal scrolling in TStringGrid


Quote
In article <87lsip$7o...@bornews.borland.com>, Johan Arthursson wrote:
> How do I disable the horizontal scrolling in a TStringGrid. Hiding the
> horizontal scrollbar is not enough because selecting the rightmost cell
> might trigger a scroll event if the cell is larger than the remaining
> TStringGrid.

Try this:

add a handler for the grids OnTopLeftChanged event. In it you do

 with sender as tstringgrid do
   if leftcol > FixedCols then
     leftcol := FixedCols;

Untested!    

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Other Threads