将用户输入从一个文本框复制到另一个文本框。 C# [英] Copying user input from one textbox to another. C#

查看:236
本文介绍了将用户输入从一个文本框复制到另一个文本框。 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,对我这么光鲜。在VS 2k8 WPF中尝试这个



我正在尝试将用户的输入字符串从一个文本框复制到另一个文本框。当我这样做时,下面的工作正常:

I'm a newbie at this so bare with me. Trying this in VS 2k8 WPF

I'm trying to copy the user's input string from one text box to another. Below works fine when I do this:

private void buttonChange_Click(object sender, RoutedEventArgs e)
 {


     string userInput = boxTop.Text;
     boxBottom.Text = userInput;


 }





以下不起作用。我遗漏了一些非常基本的东西,希望能帮助你理解这一点。





Below doesn't work. I'm missing something very basic and would like some help understanding this.

private void buttonChange_Click(object sender, RoutedEventArgs e)
  {

      string userInput = boxTop.Text;
      string userOutput = boxBottom.Text;
      userOutput = userInput;



  }

推荐答案

private void buttonChange_Click(object sender, RoutedEventArgs e)
       {

           string userInput = boxTop.Text;
           string userOutput = boxBottom.Text;
           // Values saved in variables know you can change as you have done in first step.
           boxTop.Text = userOutput;
           boxBottom.Text = userInput;

       }


这篇关于将用户输入从一个文本框复制到另一个文本框。 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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