?
Solved

How to copy field/records from DBgrid to Clipboard?

Posted on 2000-03-03
9
Medium Priority
?
276 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
Technology Partners: 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 150 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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