Recent

Author Topic: String Grid Cell. CopytoClipboard  (Read 3007 times)

feverish

  • New Member
  • *
  • Posts: 10
String Grid Cell. CopytoClipboard
« on: September 15, 2013, 05:13:53 pm »
Windows 7 x32, Lazarus 1.0.12, fpc 2.6.2, SVN revision 42478

I have a string grid on a form, and have written procedures to edit, sort, savetocsvfile, delete, etc, both cells and the complete grid contents.  I have 'Clipbrd' in the 'uses' list. I want to copy a selected cell's string to the clipboard.  This should, according to the many web references, be a simple thing to do, and the codecompletion box comes up and shows a procedural title, but I've tried and failed to do it.   I can select the cell's string contents using:-
StringGrid1.Cells[GridCol,GridRow] elsewhere in my coding but for instance
StringGrid1.Cells[0,3].CopyToClipboard and various variations all do not compile, with compiler complaints that I've given an ansi string when it wanted a boolean.
Could some kind genius please post me some code that DOES work?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: String Grid Cell. CopytoClipboard
« Reply #1 on: September 15, 2013, 05:23:31 pm »
Code: [Select]

begin
  Clipboard.AsText := StringGrid1.Cells[0,3];
end;

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

feverish

  • New Member
  • *
  • Posts: 10
Re: String Grid Cell. CopytoClipboard
« Reply #2 on: September 16, 2013, 12:36:20 pm »
Many thanks for that.  It worked like a charm.

 

TinyPortal © 2005-2018