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, 算 ...
随机推荐
- python 父子节点生成字典
lines = [(1, 1, '父1节点'), (2, 1, '1-2'), (3, 1, '1-3'), (4, 3, '1-3-4'), (5, 3, '1-3-5'), (6, 3, '1-3 ...
- Redis info笔记
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/wufaliang003/article/d ...
- linux ssh连接超时断连设置
以下均针对redhat6.5系统进行说明. 一.设置ssh超时断连 使用root用户,编辑/etc/profile文件,在 HOSTNAME='/bin/hostname' HISTIZE=30 后增 ...
- linux命令详解——tee
tee 重定向输出到多个文件 在执行Linux命令时,我们既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee命令 要注意的是:在使用管道线时,前一个命令的标准错误输出不会被tee读取. ...
- 写一个函数,对于一个给定的整数,如果它的二进制模式从正向看和反向看是一样的,那么返回true;
写一个函数,对于一个给定的整数,如果它的二进制模式从正向看和反向看是一样的,那么返回true:也就是实现这样一个函数boolean isPalindrome(int x); 分析一下,该题目主要是通过 ...
- __name__='main' 这句代码是什么意思?《读书笔记》
当我们阅读 别人的python代码都会有 if name == "main"这么一行语句,但却不知道为什么要写这个?有什么用 想知道这段代码什么意思让我们来根据例子来测试一下 我们 ...
- 记一次使用dubbo过程中版本冲突导致的坑
前言:2019年09月23日临下班,产品的一个变更需求临近尾声阶段.本地测试OK,兴致冲冲的想着发布到测试环境,验证一下没有问题,五分钟结束战斗,明天就开始下个需求了.随在CE(公司的devOps系统 ...
- maven参数详解
setting.xml主要用于配置maven的运行环境等一系列通用的属性,是全局级别的配置文件:而pom.xml主要描述了项目的maven坐标,依赖关系,开发者需要遵循的规则,缺陷管理系统,组织和li ...
- 【30分钟学完】canvas动画|游戏基础(extra1-1):美图我也行
前言 本文是接续系列教程的extra1,主要是介绍颜色系统在canvas中的应用. 本来是与extra1一起成文的,因为segmentfault莫名其妙的字数限制bug只能分割放送了. canvas操 ...
- webpack多页应用
本文主要讲了webpack怎么搭建多页应用,熟悉下webpack的基本用法. 新建文件夹,目录结构如下: 然后 cd webpack-test npm init(根目录下创建了一个pakage.jso ...