本例效果图:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button6: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{左单元+}
procedure TForm1.Button1Click(Sender: TObject);
begin
  TButton(Sender).Caption := '左单元+';
  StringGrid1.ColWidths[0] := StringGrid1.ColWidths[0] + 10;
end;

{左单元-}
procedure TForm1.Button2Click(Sender: TObject);
begin
  TButton(Sender).Caption := '左单元-';
  StringGrid1.ColWidths[0] := StringGrid1.ColWidths[0] - 10;
end;

{上单元+}
procedure TForm1.Button3Click(Sender: TObject);
begin
  TButton(Sender).Caption := '上单元+';
  StringGrid1.RowHeights[0] := StringGrid1.RowHeights[0] + 10;
end;

{上单元-}
procedure TForm1.Button4Click(Sender: TObject);
begin
  TButton(Sender).Caption := '上单元-';
  StringGrid1.RowHeights[0] := StringGrid1.RowHeights[0] - 10;
end;

{方格线+}
procedure TForm1.Button5Click(Sender: TObject);
begin
  TButton(Sender).Caption := '方格线+';
  StringGrid1.GridLineWidth := StringGrid1.GridLineWidth + 1;
end;

{方格线-}
procedure TForm1.Button6Click(Sender: TObject);
begin
  TButton(Sender).Caption := '方格线-';
  StringGrid1.GridLineWidth := StringGrid1.GridLineWidth - 1;
end;

end.

posted on 2008-03-06 21:18  万一  阅读(5114)  评论(0编辑  收藏  举报