0

私は非常に単純なことをしようとしています(少なくとも私はそう思います)。私は a を持つフォームを持っておりSplit Container、各部分 (それらはまったく 2 つです) には a しかなく、textBoxこのテキストをtextBox2. あるボックスから別のボックスにデータを渡す方法はわかりましたが、値を取得して別のボックスに渡す方法がわかりませんtextBox。繰り返しになりますが、2 つの textBoxes は 1 つの形式であるため、かなり簡単な作業になるはずです。これが私のコードです:

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //how to get the text from textBox1?
            textBox2.AppendText("I want to pass the text form textBox1");
        }
    }

また、私は使用してVisual Studio 2010います。

4

4 に答える 4

4

それは次のように簡単ですか:-

textBox2.Text = textBox1.Text;

?

于 2013-01-23T08:35:59.520 に答える
4
 private void textBox1_TextChanged(object sender, EventArgs e)
        {                
            textBox2.Text = textBox1.Text;
        }
于 2013-01-23T08:38:51.883 に答える
1

これを試して

 `private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //how to get the text from textBox1?
            textBox2 = textBox1.Text;
        }`
于 2013-01-23T08:36:10.167 に答える
1

textbox1 からテキストを取得したいだけの場合は、これを使用します。

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //how to get the text from textBox1?
            textBox2 = textBox1.Text;
        }

ただし、textbox1 から textbox2 にテキストを追加する場合は、次のようにします。

private void textBox1_TextChanged(object sender, EventArgs e)      
{
            //how to get the text from textBox1?
            textBox2.AppendText(textbox1.text);
        }
于 2013-01-23T15:15:34.807 に答える