拷贝DBGrid当前行
2006-02-04 14:00:00 来源:WEB开发网核心提示:PRocedure CopyCurrentDBLine(DBGrid: TDBGrid);var i: Integer; Line: String;begin for i := 0 to DBGrid.Columns.Count - 1 do begin if Assigned(DBGrid.Columns.G
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;
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;
更多精彩
赞助商链接