MEGA Search
20.3 Million


Sign Up
From: Jan Doggen  
Subject: TStringGrid scrolling behaviour when clicking last row
NewsGroup: borland.public.delphi.vcl.components.writing.general
Date Posted: 14-Jan-2005 at 12:10:57 PST
Hello,

Has anyone found a solution to the followung TStringgrid behaviour:

- Grid has enough cells that a vertical scrollbar appears
- Bottom cells are only partially visible
- If I click a bottom cell the grid scrolls down. The amount of scrolling is
determined by the length of the mouse down periode, so that's very
unpredictable.

To make matters worse, I'm using Peter Below's TSyncGrid to have grids
scroll synchronously, but the scroll that happens in TSyncGrid1 does not
make the linked TSyncGrid2 scroll with it! It looks as if the
WMVScroll/WMHScroll are not triggered (no WM_VSCROLL/WM_HSCROLL messages get
to TSyncGrid2?)

Jan

--
---------------------------------------------------------------------------
Jan Doggen, QSA Halfweg, The Netherlands
Please remove the spam blocker from my email address when replying directly



From: Peter Below (TeamB)  
Subject: Re: TStringGrid scrolling behaviour when clicking last row
NewsGroup: borland.public.delphi.vcl.components.writing.general
Date Posted: 14-Jan-2005 at 20:10:27 PST
In article <41e7c884@newsgroups.borland.com>, Jan Doggen wrote:
> I have now worked around it by not allowing partial cells (see procedure
> below), but I'm still interested in other solutions.

There really is no good one, this "feature" of showing partial cells when they 
are clicked on is deeply ingrained into the TCustomGrid code and very hard to 
work around. I fought it once in a project and settled finally for the same 
kind of workaround you did: not allowing partial cells...


--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



From: Jan Doggen  
Subject: Re: TStringGrid scrolling behaviour when clicking last row
NewsGroup: borland.public.delphi.vcl.components.writing.general
Date Posted: 14-Jan-2005 at 14:26:51 PST
Followup:
I tried messing with OnTopLeftChanged, but that became too complicated with
the TSyncStringGrid, because a scroll with the scroll bar fires WM_SCROLL
messages and *can* trigger OnTopLeftChanged, but an automatic scroll *will*
trigger OnTopLeftChanged and not fire WM_SCROLL messages. Too many variables
;-)

I have now worked around it by not allowing partial cells (see procedure
below), but I'm still interested in other solutions.

Jan


Type
  TCustomGridCast = Class(TCustomGrid);

procedure ResizeStringGrid(SG: TStringGrid);
  VAR
    I,Required: Integer;
  BEGIN
    with TCustomGridCast(SG) do
      begin
        required := (VisibleRowcount + FixedRows)* Gridlinewidth;
        for i:= 0 to VisibleRowcount + FixedRows-1 do
          Inc( required, RowHeights[i] );
        clientheight := required;
        required := (VisibleColcount + FixedCols)* Gridlinewidth;
        for i:= 0 to VisibleColcount + FixedCols-1 do
          Inc( required, ColWidths[i] );
        clientwidth := required;
      END;
  END; { ResizeStringGrid }

Note that when setting ClientHeight/ClientWidth you don't have to detect
scrollbars because they are outside of the client area (code was adapted
from a snippet I found for a TDBGrid where the scroll bar was included in
the calculations).


"Jan Doggen"  wrote in message
news:41e7a8a6$1@newsgroups.borland.com...
> Hello,
>
> Has anyone found a solution to the followung TStringgrid behaviour:
>
> - Grid has enough cells that a vertical scrollbar appears
> - Bottom cells are only partially visible
> - If I click a bottom cell the grid scrolls down. The amount of scrolling
is
> determined by the length of the mouse down periode, so that's very
> unpredictable.
>
> To make matters worse, I'm using Peter Below's TSyncGrid to have grids
> scroll synchronously, but the scroll that happens in TSyncGrid1 does not
> make the linked TSyncGrid2 scroll with it! It looks as if the
> WMVScroll/WMHScroll are not triggered (no WM_VSCROLL/WM_HSCROLL messages
get
> to TSyncGrid2?)
>
> Jan
>
> --
> --------------------------------------------------------------------------
-
> Jan Doggen, QSA Halfweg, The Netherlands
> Please remove the spam blocker from my email address when replying
directly
>
>