Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
HI Team
 
I have read Data From XML File like Roll No. and Name and Showed On Form after clicking on Button.
Now
I have One Text written on Label "labelText" Control.
Like
Before RUN After RUN
 
Student has Follwing Details Student has Follwing Details
 
Roll No : label1 Roll No : 1234
 
Name : label2 Name : John

 
Then I have another Labels label1 and label2 to show Data from XML File.When I click On Button at Runtime I will Get Data.
 
When I use Clipboard to copy this data on doc ..Then before RUN, I can Copy "labelText"part
BUT WHEN I RUN and COPY , then after paste It shows me Only 1234 on doc NOT all part
that specified in After RUN section..
 
PLEASE TELL ME HOW IT WILL ABLE TO PASTE ALL DATA ON DOC.
 
private void button2_Click(object sender, EventArgs e)
        {
            Clipboard.Clear();
          Clipboard.SetText(labelText.Text);
          Clipboard.SetText(label1.Text);
          Clipboard.SetText(label2.Text);
 

          
           string s = Clipboard.GetText();
 
        }
Posted 18-Feb-13 4:50am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Add all the strings into the string builder and copy the text into Clipboard
            StringBuilder sb = new StringBuilder();
            sb.Append(labelText.Text);
            sb.Append(label1.Text);
            sb.Append(label2.Text);
 

            Clipboard.Clear();
            Clipboard.SetText(sb.ToString());
 

 
            string s = Clipboard.GetText();
 
 
You can also combine two string, check below
 
'Append - adds the string in same line
'AppendLine - Adds the string in different line
            sb.AppendLine("Phone Number :" + "[your number]"); 'Combine the phone number
 
Best Regards
Muthuraja
  Permalink  
v2
Comments
Rectus at 18-Feb-13 11:28am
   
Thanks So much
 
It Copied BUT IT showed Like This
We have Upgraded Broadband Service.
 

 
Phone No:-
 
BCS FNN : -
 
365464874
 
I want Like this
Phone No :- 365464874
Muthuraja Irullandi at 18-Feb-13 11:51am
   
Hi,
Check the updated solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid