Copy the current row of DBGrid to the clipboard.

Source: Internet
Author: User
Uses
Clipbrd;

{-------------------------------------------------------------------------------
Process name: copycurrentdbline
Author: Bird
Date: 2005.10.16
Parameter: DBGrid: TDBGrid
Return Value: None
Purpose: copy the current row of DBGrid to the clipboard.
-------------------------------------------------------------------------------}
ProcedureCopycurrentdbline (DBGrid: TDBGrid );
VaR
I: integer;
Line:String;
Begin
ForI: = 0ToDBGrid. Columns. Count-1Do
Begin
IfAssigned (DBGrid. Columns. Grid. Fields [I])Then
IfLine =''Then
Line: = DBGrid. Columns. Grid. Fields [I]. Text
Else
Line: = line + ''+ DBGrid. Columns. Grid. Fields [I]. text;
End;
Clipboard. settextbuf (pchar (line ));
End;

{-------------------------------------------------------------------------------
Process name: copydbdata
Author: Bird
Date: 2005.10.16
Parameter: DBGrid: TDBGrid
Return Value: None
Purpose: Copy all the content of DBGrid to the clipboard.
-------------------------------------------------------------------------------}
ProcedureCopydbdata (DBGrid: TDBGrid );
Const
CRLF = #13 #10;
VaR
I: integer;
Lines:String;
Bookmark: pointer;
Begin
Bookmark: = DBGrid. datasource. dataset. getbookmark;
DBGrid. datasource. dataset. first;

While NotDBGrid. datasource. dataset. EOFDo
Begin
ForI: = 0ToDBGrid. Columns. Count-1Do
Begin
IfAssigned (DBGrid. Columns. Grid. Fields [I])Then
IfLines =''Then
Lines: = DBGrid. Columns. Grid. Fields [I]. Text
Else
IfI = 0Then
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.