Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to copy data from selected rows in a Data Grid to a clipboard. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Copy selected rows in a DBGrid to a clipboard. 03-Mar-04
Category
Database-VCL
Language
CBuilder 3.x
Views
658
User Rating
8.5
# Votes
2
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			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  }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC