实例3:
本例功能:
1、修改 TStringGrid的默认宽与高;
2、添加行;
3、确认当前单元并赋值.
实例图形:
unit Unit12;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Grid,
FMX.Layouts;
type
TForm12 = class(TForm)
StringGrid1: TStringGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
StringColumn1: TStringColumn;
StringColumn2: TStringColumn;
StringColumn3: TStringColumn;
StringColumn4: TStringColumn;
StringColumn5: TStringColumn;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
implementation
{$R *.fmx}
{修改表格的宽度和行高}
procedure TForm12.Button1Click(Sender: TObject);
begin
StringGrid1.Width:= 500;
StringGrid1.RowHeight := 18;
TButton(Sender).Text := '宽与高';
end;
procedure TForm12.Button2Click(Sender: TObject);
{添加一行}
begin
StringGrid1.RowCount := StringGrid1.RowCount + 1;
TButton(Sender).Text:= '加一行';
end;
{添加一列:addItem}
{所有单元}
procedure TForm12.Button3Click(Sender: TObject);
var
c,r: Integer;
begin
for c := 0 to StringGrid1.ColumnCount - 1 do
for r := 0 to StringGrid1.RowCount - 1 do
StringGrid1.Cells[c,r] := Format('列:%d,行:%d', [c,r]);
end;
end.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步