waeberd
asked on
TScrollbox: How can I prevent automatic "scrollintoview" of large components?
Hi, a very annoying problem using BDS2006:
I have a Form with a Scrollbox containing two TStringGrids aligned vertically.
The StringGrids are sized so that the bottom one is only partly displayed on the Form, the ScrollBox allows accessing the whole StringGrid.
The problem: if I click the bottom StringGrid (which is partly visible), the Scrollbox "jumps" so that the clicked StringGrid scrolls into view completely. I want to be able to click the StringGrid without any "jump effect" on the scrollbox!
How can I do this?
I have a Form with a Scrollbox containing two TStringGrids aligned vertically.
The StringGrids are sized so that the bottom one is only partly displayed on the Form, the ScrollBox allows accessing the whole StringGrid.
The problem: if I click the bottom StringGrid (which is partly visible), the Scrollbox "jumps" so that the clicked StringGrid scrolls into view completely. I want to be able to click the StringGrid without any "jump effect" on the scrollbox!
How can I do this?
unit1.pas
==============================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.
==============================
unit1.dfm
==============================
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 533
ClientWidth = 742
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ScrollBox1: TScrollBox
Left = 0
Top = 0
Width = 742
Height = 533
Align = alClient
TabOrder = 0
ExplicitWidth = 688
object StringGrid1: TStringGrid
Left = 5
Top = 5
Width = 668
Height = 300
RowCount = 20
TabOrder = 0
end
object StringGrid2: TStringGrid
Left = 5
Top = 311
Width = 668
Height = 400
RowCount = 20
TabOrder = 1
end
end
end
==============================
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Damn, I was slow... :)
Hypo,
Your method is actually simpler to implement (both do the same thing by stubbing the method).
Russell
Your method is actually simpler to implement (both do the same thing by stubbing the method).
Russell
Yeah,
It's a quick n' dirty sollution I saw somewhere on this forum a couple of months ago, it was another control, but the principals was the same; and It's a nice way to tweak your standard VCL's when you need to change their behaviour to test something quickly. :)
regards
Hypo
It's a quick n' dirty sollution I saw somewhere on this forum a couple of months ago, it was another control, but the principals was the same; and It's a nice way to tweak your standard VCL's when you need to change their behaviour to test something quickly. :)
regards
Hypo
I have used it before, but my delphi is starting to get rusty from too much C++ work ;-)
Russell
Russell
ASKER
wow, thanks a million!
ASKER
Thanks a lot! Fast, helpful answers!