调节它的自动适应属性
TCheckListBox更好用

解决方案 »

  1.   

    //pas
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, ValEdit, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        GroupBox1: TGroupBox;
        Panel1: TPanel;
        ScrollBar1: TScrollBar;
        Panel2: TPanel;
        ScrollBar2: TScrollBar;
        Edit1: TEdit;
        Edit2: TEdit;
        Memo1: TMemo;
        procedure ScrollBar1Change(Sender: TObject);
        procedure FormShow(Sender: TObject);
        procedure ScrollBar2Change(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}uses
      Math;procedure TForm1.ScrollBar1Change(Sender: TObject);
    begin
      Panel2.Top := - TScrollBar(Sender).Position;
    end;procedure TForm1.FormShow(Sender: TObject);
    begin
      ScrollBar1.Min := 0;
      ScrollBar1.Max := Max(Panel2.Height - Panel2.Parent.ClientHeight, 0);
      ScrollBar2.Min := 0;
      ScrollBar2.Max := Max(Panel2.Width - Panel2.Parent.ClientWidth, 0);
      Panel2.Top := 0;
      Panel2.Left := 0;
    end;procedure TForm1.ScrollBar2Change(Sender: TObject);
    begin
      Panel2.Left := - TScrollBar(Sender).Position;
    end;end.//dfm
    object Form1: TForm1
      Left = 192
      Top = 107
      Width = 544
      Height = 375
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnShow = FormShow
      PixelsPerInch = 96
      TextHeight = 13
      object GroupBox1: TGroupBox
        Left = 152
        Top = 144
        Width = 185
        Height = 105
        Caption = 'GroupBox1'
        TabOrder = 0
        object Panel1: TPanel
          Left = 2
          Top = 15
          Width = 165
          Height = 72
          Align = alClient
          BevelOuter = bvNone
          TabOrder = 0
          object Panel2: TPanel
            Left = 0
            Top = 0
            Width = 290
            Height = 233
            BevelOuter = bvNone
            TabOrder = 0
            object Edit1: TEdit
              Left = 24
              Top = 64
              Width = 121
              Height = 21
              TabOrder = 0
              Text = 'Edit1'
            end
            object Edit2: TEdit
              Left = 24
              Top = 24
              Width = 121
              Height = 21
              TabOrder = 1
              Text = 'Edit2'
            end
            object Memo1: TMemo
              Left = 160
              Top = 24
              Width = 185
              Height = 89
              Lines.Strings = (
                'Memo1')
              TabOrder = 2
            end
          end
        end
        object ScrollBar1: TScrollBar
          Left = 167
          Top = 15
          Width = 16
          Height = 72
          Align = alRight
          Kind = sbVertical
          PageSize = 0
          TabOrder = 1
          OnChange = ScrollBar1Change
        end
        object ScrollBar2: TScrollBar
          Left = 2
          Top = 87
          Width = 181
          Height = 16
          Align = alBottom
          PageSize = 0
          TabOrder = 2
          OnChange = ScrollBar2Change
        end
      end
    end