Delphi XE2 之 FireMonkey 入门(43) - 控件基础: TStringGrid、TGrid
1、它们的列对象分别是: TStringColumn、TColumn;
2、TStringGrid 比 TGrid 多出了 Cells[] 属性.
因为 TGrid 没有 Cells[] 属性, 暂时不方便使用; 我尝试取其当前单元值时竟然用了这样的代码:
(Grid1.Columns[Grid1.ColumnIndex].CellControlByRow(Grid1.Selected) as TTextCell).Text
TStringGrid 测试:
{ 设计时放好 StringGrid1, 运行时填充数据 }
procedure TForm1.FormCreate(Sender: TObject);
var
i,c,r: Integer;
begin
StringGrid1.AlternatingRowBackground := True;
StringGrid1.UseSmallScrollBars := True;
for i := to do //从设计时添加列比这方便
begin
with TStringColumn.Create(Self) do
begin
Parent := StringGrid1;
Width := StringGrid1.ClientWidth / ;
end;
end;
StringGrid1.RowCount := ;
for c := to StringGrid1.ColumnCount - do
for r := to StringGrid1.RowCount - do
StringGrid1.Cells[c, r] := Format('%d,%d', [c, r]);
end;
{ 取当前单元值 }
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(StringGrid1.Cells[StringGrid1.ColumnIndex, StringGrid1.Selected]);
end;
成员概览:
{ TCustomGrid }
public
constructor Create(...); override; //
destructor Destroy; override; //
function ColumnByIndex(...): TColumn; //根据索引获取列对象
function ColumnByPoint(...): TColumn; //根据位置获取列对象
function RowByPoint(...): Integer; //根据位置获取行号
procedure AddObject(...); override; //
property TopRow: Integer ...; //获取可见的首行的行号
property VisibleRows: Integer ...; //获取可见的行总数
property ColumnCount: Integer ...; //列数(也是只读)
property ColumnIndex: Integer ...; //获取或设置列索引
property Columns[Index: Integer]: TColumn ...; //以数组索引的方式获取列对象
property RowCount: Integer ...; //行数(可读写)
property Selected: Integer ...; //当前行号
property OnGetValue: TOnGetValue ...; //取值时
property OnSetValue: TOnSetValue ...; //赋值时
published
property StyleLookup; //
property AlternatingRowBackground: Boolean ...; //是否使用交替背景; 默认 False
property CanFocus default True; //
property DisableFocusEffect default True; //是否取消焦点特效
property RowHeight: Single ...; //行高
property ShowSelectedCell: Boolean ...; //是否呈现单元选择效果; 默认 True
property ShowVertLines: Boolean ...; //是否显示竖格线
property ShowHorzLines: Boolean ...; //是否显示横格线
property ShowHeader: Boolean ...; //是否显示表格头
property ReadOnly: Boolean ...; //是否只读; 默认 False
property TabOrder; //
property OnEdititingDone: TOnEdititingDone ...; //输入时
end;
{ TGrid }
TGrid = class(TCustomGrid)
published
property RowCount; //
property OnGetValue; //
property OnSetValue; //
end;
{ TStringGrid }
public
property Cells[ACol, ARow: Integer]: string ...; //
published
property RowCount; //
end;
Delphi XE2 之 FireMonkey 入门(43) - 控件基础: TStringGrid、TGrid的更多相关文章
- Delphi XE2 之 FireMonkey 入门(44) - 控件基础: TTreeView、TTreeViewItem
Delphi XE2 之 FireMonkey 入门(44) - 控件基础: TTreeView.TTreeViewItem TScrollBox -> TCustomTreeView -> ...
- Delphi XE2 之 FireMonkey 入门(42) - 控件基础: TComboBox、TComboEdit
Delphi XE2 之 FireMonkey 入门(42) - 控件基础: TComboBox.TComboEdit TListBox 有两个兄弟 TComboListBox.TComboEditL ...
- Delphi XE2 之 FireMonkey 入门(41) - 控件基础: TListBox
Delphi XE2 之 FireMonkey 入门(41) - 控件基础: TListBox TScrollBox -> TCustomListBox -> TListBox; 其元素项 ...
- Delphi XE2 之 FireMonkey 入门(40) - 控件基础: TMemo
Delphi XE2 之 FireMonkey 入门(40) - 控件基础: TMemo 值得注意的变化: 1.其父类 TScrollBox 的许多特性也很有用处, 如: Memo1.UseSma ...
- Delphi XE2 之 FireMonkey 入门(39) - 控件基础: TScrollBox、TVertScrollBox、TFramedScrollBox、TFramedVertScrollBox
Delphi XE2 之 FireMonkey 入门(39) - 控件基础: TScrollBox.TVertScrollBox.TFramedScrollBox.TFramedVertScrollB ...
- Delphi XE2 之 FireMonkey 入门(38) - 控件基础: TPopupMenu、TMenuItem、TMenuBar、TMainMenu
Delphi XE2 之 FireMonkey 入门(38) - 控件基础: TPopupMenu.TMenuItem.TMenuBar.TMainMenu 相关控件: TMenuBar.TPopup ...
- Delphi XE2 之 FireMonkey 入门(37) - 控件基础: TControl 概览
Delphi XE2 之 FireMonkey 入门(37) - 控件基础: TControl 概览 { TControl } public constructor Create(...); ov ...
- Delphi XE2 之 FireMonkey 入门(36) - 控件基础: TForm
Delphi XE2 之 FireMonkey 入门(36) - 控件基础: TForm 当我第一次读取 Form1.StyleLookup 并期待出现 "formstyle" 时 ...
- Delphi XE2 之 FireMonkey 入门(35) - 控件基础: TFmxObject: 其它
Delphi XE2 之 FireMonkey 入门(35) - 控件基础: TFmxObject: 其它 TFmxObject 增加了 TagObject.TagFloat.TagString, 算 ...
随机推荐
- 从零开始学MySQL(二)
鉴于上节篇幅以安装为主,因此对于调用mysql所需要使用的“命令”只是略微提及.随之而来就会带给读者诸多不解了,因为你会思考,这串长长的字符到底有什么特殊的含义呢?聪明的你可能早就抱着好奇心去“摆渡” ...
- 监控mysql的存储引擎
监控mysql 显示进程状态变量 mysql> show variables like '%thread%'; +----------------------------+----------- ...
- win 与Linux 的hosts文件地址
win(phpstudy):C:/Windows/System32/drivers/etc/hosts linux: /etc/hosts
- 自动化运维——HelloWorld(一)
1.HelloWorld vi first_shell.sh #!/bin/bash #Filename: first_shell.sh #auto echo hello world! #by aut ...
- .htaccess A网站单页面301到B网站单页面
.htaccess 301问题 A网站 a.com/a.html 301到 B网站 b.com/b.html RewriteRule ^a.com/a.html$ http://www.b. ...
- Django学习系列6:使用selenium测试用户交互
学习系列5中的单元测试有报错信息,这儿来编写functional_tests.py文件,扩充其中的功能测试 # File: functional_test.py # Author: Rxf # Cre ...
- mybatis javabean字段与数据库字段的映射
结论:未作映射的字段没有值,但是数据库中实际是有值的,说明如果带下划线的字段未作映射,返回值是不会有值的,只有映射了的字段以及不带下划线的字段(默认映射)才有返回值 1.bean属性 public c ...
- linux下的命令和常见问题笔记
nginx的三大功能: 1.http服务 2.反向代理 3.负载均衡 2.当nginx重启报:[root@localhost logs]# service nginx reloadReloading ...
- 那些年我写过的mysql命令
建表语句 #mysql5.7适用create table testfy ( id int primary key AUTO_INCREMENT, clipid int comment '影片编号', ...
- Codeforces Round #568 (Div. 2) C2. Exam in BerSU (hard version)
链接: https://codeforces.com/contest/1185/problem/C2 题意: The only difference between easy and hard ver ...