本文整理自网络,侵删。
StringGrid 实例3: 本例功能: 1、修改 TStringGrid的默认宽与高; 2、添加行; 3、确认当前单元并赋值.实例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.
来源:https://www.cnblogs.com/lingzhiwen/p/3322566.html
相关阅读 >>
Delphi rest application 与 webbroker application 区别
Delphi用多媒体库 bass.dll 播放 mp3 - 打开、播放、暂停、停止
Delphi sysutils.lastdelimiter - 判断一个字符串在另一个字符串中最后出现的位置
更多相关阅读请进入《Delphi》频道 >>