Delphi StringGrid 实例2:1、获取 StringGrid 的行数、列数; 2、给单元赋值


本文整理自网络,侵删。

 
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

相关阅读 >>

Delphi 用sql语句添加删除修改字段

Delphi 中文字符串函数问题rightstr

Delphi 苹果系统弹出链接

Delphi spcomm的一些用法注意

Delphi删除整个目录及目录下的文件

Delphi 阿里云发送短信的Delphi单元

Delphi 比较完整的listview1用法

Delphi 将listview保存为txt

Delphi 枚举消息钩子的代码

Delphi firedac tfddatamove 导出csv

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...