DBGrid相关技术整理
来源:互联网 发布:现代远程网络教育 编辑:程序博客网 时间:2024/04/29 21:30
DBGrid相关技术整理;
注:对于DBGrid相关属性、方法的学习融入到技术整理过程中
一,多选
设置属性:
Options->dgMultiSelect = True;
->dgRowSelect = True;
应用属性:
SelectedRows;
操作方法:
-Ctrl + Mouse Clicks
-Shift + Arrow Keys
For example:
1,取得所选行某个字段的值的合计:
procedure TForm1.btnDoSumClick(Sender: TObject);
var
i: Integer;
sum: Single;
begin
if DBGrid1.SelectedRows.Count > 0 then
begin
sum := 0;
with DBGrid1.DataSource.DataSet do
begin
for i := 0 to DBGrid1.SelectedRows.Count - 1 do
begin
GotoBookmard(Pointer(DBGrid1.SelectedRows.Items[i]));
sum := sum + AdoQuery1.FieldByName('Size').asfloat;
end;
end;
edtSizeSum.Text := FloattoStr(sum);
end;
end;
//用edtSizeSum来接收计算来的合计值
2,全选DBGrid:
procedure DBGridSelectAll(AGrid: TDBGrid) ;
begin
AGrid.SelectedRows.Clear;
with AGrid.DataSource.DataSet do
begin
DisableControls;
First;
try
while not EOF do
begin
AGrid.SelectedRows.CurrentRowSelected := True;
Next;
end;
finally
EnableControls;
end;
end;
end;
深入了解:
1,SelectedRows:
The TDBGrid component keeps all the selections as Bookmarks in a TStringList,
and all the Bookmarks must be converted to a Pointer (what they really are) before using it.
&
The SelectedRows property is an object of type TBookmarkList.
We can use the SelectedRows property to, for example:
--get the number of rows selected,
--clear the selection(unselect),
--delete all the selected records,
--check whether a particular record is selected.
2,运行时设置DBGrid的多选属性
DBGrid1.Options := DBGrid1.Options + [dgMultiSelect];
//以上部分内容取自http://delphi.about.com/od/usedbvcl/l/aa032503a.htm
二,加入其它控件
http://delphi.about.com/od/usedbvcl/l/aa082003a.htm
http://delphi.about.com/od/usedbvcl/l/aa082003a.htm
三,颜色设置
http://delphi.about.com/od/usedbvcl/l/aa031699.htm
- DBGrid相关技术整理
- spring相关技术整理
- spring相关技术整理
- SAAS相关技术要点整理
- 最近整理的相关技术
- 最新数据库相关技术整理
- Python GUI编程-了解相关技术[整理]
- oracle flashback技术相关知识整理
- Andriod网络优化相关技术点整理
- 网页前端的相关技术整理
- dbgrid
- [VB]RS和DBGrid的相关操作
- 相关技术摘要_使用db2摘要(未做整理)
- 整理的 Oracle 基于SQL Plus 以及技术相关
- Windows Phone开发相关技术要点已经整理成书了
- 基于iOS上MDM技术相关资料整理及汇总
- 基于IOS上MDM技术相关资料整理及汇总
- 自己整理_银行核心系统相关技术知识
- Asp.Net中OnClientClick与OnClick之我见
- BMP
- 我将从哪里开始?
- Java Annotation手册
- 什么是Unicode编码
- DBGrid相关技术整理
- 南瓜盅炖蛋
- 嗯,我最闲。
- Flash杂志《Summer tree》即将完成
- JAVA操作XML三(更新):修改或删除XML内容
- 要写软件项目管理实践报告。。头疼!有人能给点建议吗?
- vi中结合ctag查找函数声明
- 尝试数据库被标记为RESTORING的处理方式
- SysUtils.StrScan、SysUtils.StrRScan、SysUtils.StrPos函数