本文整理自网络,侵删。
StringGrid 实例2:1、获取 StringGrid 的行数、列数; 2、给单元赋值.实例2:
本例功能:1、获取 StringGrid 的行数、列数;2、给单元赋值.
运行效果图:
//示例代码:
//获取总列数,和总行数
procedure TForm12.Button1Click(Sender: TObject);
var
cCount,rCount: Integer;
begin
cCount := StringGrid1.ColumnCount; {获取总列数}
rCount := StringGrid1.RowCount; {获取总行数}
Caption := Format('总列数: %d ,总行数: %d', [cCount, rCount]); {显示在标题}
end;
//给每一个单元格赋值
procedure TForm12.Button2Click(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/3321951.html
相关阅读 >>
idhttp访问网页出现socket error #10054错误
Delphi 数据类型cardinal 怎么转换成 string?
Delphi xe ioutils tpath(结构体) 的方法与属性
Delphi android实例-trectangle加载图片(xe8+小米2)
Delphi中 tstringlist和thashedstringlist的性能对比
Delphi strutils.leftstr、strutils.rightstr - 提取左右字符串
更多相关阅读请进入《Delphi》频道 >>