1 2 /* this code will help you copy data from selected rows in a Datagrid to a clipboard 3 I'm not sure if it will work in CBuilder 1.0 4 */ 5 6 void __fastcall TForm1::Button1Click(TObject *Sender) 7 { 8 9 int i, j; 10 String sData=""; 11 char tab ='\t'; 12 char CR ='\r'; 13 TClipboard *SysClip = new TClipboard(); 14 15 //used to create to copy the column Header 16 for(i=0;i< DBGrid1->SelectedRows->Count;i++){ 17 sData += UpperCase(DBGrid1->Fields[i]->DisplayName); 18 if(i != DBGrid1->SelectedRows->Count){ 19 sData += '\,' +tab; //tab 20 } 21 sData += CR; //carriage return 22 } 23 if ( DBGrid1->SelectedRows->Count>0){ 24 for(i=0;i< DBGrid1->SelectedRows->Count;i++){ 25 DBGrid1->DataSource->DataSet->GotoBookmark((void *) 26 DBGrid1->SelectedRows->Items[i].c_str()); 27 28 for(j=0;j<DBGrid1->DataSource->DataSet->FieldCount;j++){ 29 sData+= DBGrid1->DataSource->DataSet->Fields->Fields[j]->AsString ; 30 if(j>0){ 31 sData += '\,'+tab; //tab 32 } 33 } 34 sData += '\,'+CR; //carriage return 35 } 36 37 } 38 39 SysClip->AsText =sData; 40 SysClip->Free(); 41 42 }