首页 > 解决方案 > 如何在按钮后面传递文本并将其传递给文本框?像“预览”

问题描述

  1. 按钮内有一个小文本:

    private void TASKTOVSWRBTN_Click(object sender, EventArgs e)
    {
     Clipboard.SetText("The Network Operations Center is requesting a field engineer to attend the site in order to solve this issue. " +
        "\n Check carefully the hardware, cabling or passive network equipments, so the issue can be easily identified." +
        "\n If support is needed, please ring us, we will be here 24 / 7 to help.");
    
  2. 我想预览文本框内按钮后面的文本

  3. 将文本复制到剪贴板。

  4. 目前我只能从按钮复制​​到剪贴板。但我想在将其发送到剪贴板之前查看文本,例如预览。

文本框的图片

标签: c#winformstextclipboardpreview

解决方案


那只是:

private void TASKTOVSWRBTN_Click(object sender, EventArgs e)
{
    // "preview" the message in the textbox:
    bunifuMetroTextbox1.Text = "The Network Operations Center is requesting a field engineer to attend the site in order to solve this issue. " +
       "\n Check carefully the hardware, cabling or passive network equipments, so the issue can be easily identified." +
       "\n If support is needed, please ring us, we will be here 24 / 7 to help.";
}

private void btnGetIt_Click(object sender, EventArgs e)
{
    // if the textbox is not empty, then place its contents on the clipboard
    if (bunifuMetroTextbox1.Text.Trim().Length > 0)
    {
        Clipboard.SetText(bunifuMetroTextbox1.Text.Trim());
    }
}

推荐阅读