首页 > 学院 > 开发设计 > 正文

拷贝DBGrid当前行

2019-11-18 18:04:38
字体:
来源:转载
供稿:网友
PRocedure CopyCurrentDBLine(DBGrid: TDBGrid);
var
  i: Integer;
  Line: String;
begin
  for i := 0 to DBGrid.Columns.Count - 1 do begin
    if Assigned(DBGrid.Columns.Grid.Fields[i]) then
      if Line = '' then
        Line := DBGrid.Columns.Grid.Fields[i].Text
      else
        Line := Line + ' ' + DBGrid.Columns.Grid.Fields[i].Text;
  end;
  Clipboard.SetTextBuf(pchar(Line));
end;
//感谢深思提供技术支持:)

procedure CopyDBData(DBGrid: TDBGrid);
const
  CRLF = #13#10;
var
  i: Integer;
  Lines: String;
  BookMark: Pointer;
begin
  BookMark := DBGrid.DataSource.DataSet.GetBookmark;
  DBGrid.DataSource.DataSet.First;
 
  while not DBGrid.DataSource.DataSet.Eof do begin
    for i := 0 to DBGrid.Columns.Count - 1 do begin
      if Assigned(DBGrid.Columns.Grid.Fields[i]) then
        if Lines = '' then
          Lines := DBGrid.Columns.Grid.Fields[i].Text
        else
          if i = 0 then
            Lines := Lines + DBGrid.Columns.Grid.Fields[i].Text
          else
            Lines := Lines + ' ' + DBGrid.Columns.Grid.Fields[i].Text;
    end;
    Lines := Lines + CRLF;
    DBGrid.DataSource.DataSet.Next;
  end;
  ClipBoard.SetTextBuf(PChar(Lines));
  DBGrid.DataSource.DataSet.GotoBookmark(BookMark);
end;

上一篇:让Fastreport3.x支持中文PDF的输出

下一篇:帖个HOOK鼠标滚轮滚动的DLL

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
学习交流
热门图片

新闻热点

疑难解答

图片精选

网友关注