Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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

1 solution

Hi,
Add all the strings into the string builder and copy the text into Clipboard
C#
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

VB
'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
 
Share this answer
 
v2
Comments
[no name] 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900