Linking a Text Box to a variable?

Posted by cam on Stack Overflow See other posts from Stack Overflow or by cam
Published on 2010-03-28T15:41:23Z Indexed on 2010/03/28 15:43 UTC
Read the original article Hit count: 129

Filed under:
|

I would like to have direct access to the text inside a textbox on another form, so I added a public variable _txt to a form and added an event like so:

        private void richTextBox1_TextChanged(object sender, EventArgs e)
    {
        _txt = richTextBox1.Text;
    }

But the form is loaded like this:

        public FrmTextChild(string text)
    {
        InitializeComponent();
        _txt = text;
        richTextBox1.Text = _txt;
        Text = "Untitled.txt";
    }

Is there a better way to directly link the two?

© Stack Overflow or respective owner

Related posts about c#

Related posts about textbox