Delphi实现DBGrid全选和反选功能
2022-12-28 14:36:11 作者:admin
本文整理自网络,侵删。
Delphi实现Dbgrid全选和反选、清除全选的功能,不管是在Delphi下,还是在WEB开发中,这种功能都是很实用的,是进行数据批量操作的基础。本模块就是实现了为Delphi的DBGrid数据列表增加全选内容、清除全选的功能,很实用了,代码内容如下:
//全选procedure TFrameCustSelector.ToolButton1Click(Sender: TObject);var OldCurrent: TBookmark;begin OldCurrent := DBGrid1.DataSource.DataSet.Bookmark; DBGrid1.DataSource.DataSet.DisableControls; DBGrid1.DataSource.DataSet.First ; while not DBGrid1.DataSource.DataSet.Eof do begin DBGrid1.SelectedRows.CurrentRowSelected := true; DBGrid1.DataSource.DataSet.Next; end; DBGrid1.DataSource.DataSet.GotoBookmark(OldCurrent); DBGrid1.DataSource.DataSet.EnableControls;end;//清除全选procedure TFrameCustSelector.ToolButton2Click(Sender: TObject);var OldCurrent: TBookmark;begin OldCurrent := DBGrid1.DataSource.DataSet.Bookmark; DBGrid1.DataSource.DataSet.DisableControls; DBGrid1.DataSource.DataSet.First ; while not DBGrid1.DataSource.DataSet.Eof do begin DBGrid1.SelectedRows.CurrentRowSelected := False; DBGrid1.DataSource.DataSet.Next; end; DBGrid1.DataSource.DataSet.GotoBookmark(OldCurrent); DBGrid1.DataSource.DataSet.EnableControls;end;//反选procedure TFrameCustSelector.ToolButton3Click(Sender: TObject);varOldCurrent: TBookmark;begin OldCurrent := DBGrid1.DataSource.DataSet.Bookmark; DBGrid1.DataSource.DataSet.DisableControls; DBGrid1.DataSource.DataSet.First ; while not DBGrid1.DataSource.DataSet.Eof do begin DBGrid1.SelectedRows.CurrentRowSelected := not DBGrid1.SelectedRows.CurrentRowSelected; DBGrid1.DataSource.DataSet.Next; end; DBGrid1.DataSource.DataSet.GotoBookmark(OldCurrent); DBGrid1.DataSource.DataSet.EnableControls;end;
相关阅读 >>
Delphi判断字符串中是否包含汉字,并返回汉字位置
Delphi图片base64编码
Delphi中分隔字符串函数的使用
Delphi getexplorerpid获取系统explorer.exe进程id
Delphi tms web core tedit编辑输入框属性展示
Delphi 按f11程序全屏
Delphi共享软件防破解的实用招法
Delphi遍历所有控件
Delphi xe 移动平台 showmodal 范例
Delphi 通�^窗口句柄或窗口标题得到进程句柄
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码