Lazarus DBGrid使用
Option:
1.dgEditing:
对单元内容进行编辑,需要点击鼠标2次,第1次选中单元,第2次进入编辑模式;
为了避免要点2次才可编辑,可以设置dgAlwaysShowEditor=true,则可以直接编辑
2.dgMultiselect:可以选择多行;
3.dgRowselect:可以选择整行;
注:当dgRowselect=true时,则不能选择dgEditing选项
Since DBGrid inherits a virtual method DoCopyToClipboard from its ultimate ancestor, TCustomGrid, you can solve this by subclassing:
点击DBGrid行,选择整行数据进行Copy,需要重载TCustomDBGrid DoCopyToClipboard方法,如下:
-
type
-
TDBGrid = class(DBGrids.TDBGrid)
-
protected
-
procedure DoCopyToClipboard; override;
-
end;
-
-
procedure TDBGrid.DoCopyToClipboard;
-
var
-
s: String;
-
c: Integer;
-
begin
-
s := '';
-
for c := 0 to Columns.Count-1 do
-
s := s + #9 + Columns[c].field.AsString;
-
if s <> '' then Delete(s, 1, 1);
-
Clipboard.AsText := s;
-
end;
TDBGrid = class(DBGrids.TDBGrid),子类和父类同名,需要这样写。
Put the redeclaration of TDBGrid into the same unit in which you want to apply it, and put it in front of the first usage of a DBGrid instance. Or, if there are several places which you want to be handled in the same way, put it into a separate unit and mention this unit at the end of the uses list of all forms needing it. This way the compiler is "deceived", and he executes the modified DoCopyToClipbpoard rathter than the original one when CTRL+C is pressed.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)