Solved

How to copy field/records from DBgrid to Clipboard?

Posted on 2000-03-03
9
246 Views
Last Modified: 2010-04-04
How does one copy complete records(text only) into clip board programatically (iewith out using ctrl-C key combination)
Thanks venks
0
Comment
Question by:venks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 2579637
Well, this is easy. Write a method which collects the text snippets (say separated by tabulators, then you can easily copy them to e.g. Word) and use Clipboard.AsText := CollectedText; to set the clipboard.

Ciao, Mike
0
 
LVL 1

Author Comment

by:venks
ID: 2579648
I know that.But can you give me the code
(to use it with any table)
thanks
venks
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2579697
No problem:

procedure CopyCurrentRecordToClipBoard(Dataset: TDataSet);

var
  I: Integer;
  S: String;

begin
  S := '';
  with Dataset do
  for I := 0 to FieldCount - 1 do
  begin
    if Fields[I].DataType = ftString then S := S + Fields[I].AsString + #9;
  end;
  Clipboard.AsText := S;
end;

Ciao, Mike
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Lischke
ID: 2579706
Btw. you may want to strip out the last tabulator character with:

  if S > '' then SetLength(S, Length(S) - 1);

Ciao, Mike
0
 
LVL 1

Author Comment

by:venks
ID: 2580294
Dear lishke
Thanks
What happens if there is a memo field?
venks
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2580340
What memo? Where? As source for the clipboard operation? If yes then it is even simpler:

  Clipboard.AsText := MyMemo.Text;

for all the text or

  Clipboard.AsText := MyMemo.SelText;

just for the selected text.

Ciao, Mike
0
 
LVL 1

Author Comment

by:venks
ID: 2580570
What i meant was that there could be a DBMemo field.
Thanks for the answer.If you post an answer i will award the points.
thanks
venks
0
 
LVL 10

Accepted Solution

by:
Lischke earned 50 total points
ID: 2580603
Actually, a DB memo is the same as a memo with the slight difference that it get its content from a database (and can store it there).

For future answers you can pick the link "accept comment as answer" which is shown on the green bars if nobody has proposed an answern already.

Ciao, Mike
0
 
LVL 1

Author Comment

by:venks
ID: 2582209
Thanks
venks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question