如何将多个值从表单复制到剪贴板 [英] How to Copy Multiple Values from Form to Clipboard

查看:52
本文介绍了如何将多个值从表单复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI团队



点击按钮后,我已读取数据来自XML文件,如卷号和名称以及表单显示。

现在

我有一个文字写在标签labelText控制。

喜欢

RUN之前 RUN后



学生有详细信息学生有详细信息



卷号: label1 卷号:1234



名称:label2 姓名:John





然后我有另一个标签label1和label2来显示XML文件中的数据。当我在运行时单击按钮时我将获取数据。



当我使用剪贴板在doc上复制这些数据时..然后在RUN之前,我可以复制labelText部分

但是当我运行和复制时,那么粘贴后它显示我只有1234在doc上并非所有部分

在After RUN部分指定..



请告诉我它将如何可以在DOC上粘贴所有数据。



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();

        }

推荐答案



将所有字符串添加到字符串中构建器并将文本复制到剪贴板中

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





最好的问候

Muthuraja



Best Regards
Muthuraja


这篇关于如何将多个值从表单复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆