Solved

How to copy field/records from DBgrid to Clipboard?

Posted on 2000-03-03
9
226 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now