How can I Copy the content in a cell of dxDBGrid to clipboard?

The dxDBGrid is in Browse state,but I want to copy the contents of a cell to clipboard.

How can I do?
SingBabysAsked:
Who is Participating?
 
nestoruaConnect With a Mentor Commented:
HI,
Do the following:
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
  AClipBoard.AsText:=Column.Field.AsString;
end;
Here AClipBoard is a variable of type TClipBoard
(If you read the previous comment you know how to create and free it).
Sincerely,
Nestorua.
0
 
SingBabysAuthor Commented:
I'm waiting for the answer.
0
 
kretzschmarCommented:
usual u use directly the dataset which is assigned to the grid for this

a sceleton

implementation
{$R *.DFM}

uses Clipbrd;
var AClipBoard : TClipBoard;

procedure TForm1.Button1Click(Sender: TObject);
begin
  AClipBoard.AsText := Dataset.FieldByName('FieldNameYouWant').AsString;
end;

initialization
  AClipBoard := TClipBoard.Create;
finalization
  AClipBoard.Free;
end.

meikl ;-)
0
 
Lee_NoverCommented:
ClipBoard is a global object and doesn't need to be created
about dxDBGrid .. forgot it's methods and properties .. been using cxGrid (ver 4+) since it came out
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.