Retrieve Values from One Form to Another in Windows application using C#
<p>I have a login form and ChangePassword form. I want to retrieve the value of username entered in the Login form at the time of logging.</p>

<p>I have created a property named as RetUserName as follows:</p>

<pre><code> public partial class frmLogin : Form
    {
        private string UseNam;
        public string RetUserName
        {
            get { return UseNam; }
            set { UseNam = value;}
        }
   }
</code></pre>

<p>In the button click event i have written the following code so that the value of the property is set:</p>

<pre><code>this.RetUserName = (string)txtUserName.Text;
</code></pre>

<p>Now to retrieve the value of the property i have used the following coding in the form_load event of the changepassword form:</p>

<p>Form_Load Event:</p>

<pre><code>        frmLogin objLogin = new frmLogin();
        string UserName1 = objLogin.RetUserName;
        MessageBox.Show("NAME : " + UserName1);
        txtUserName.Text = UserName1;
</code></pre>

<p>Now when I execute the above program does not generate any errors, however the value entered by the user in the login form is not displayed in the changepassword form.</p>

<p>Can anyone let me know how should I change the coding so that I can retrieve the values entered by user in the login form to be displayed in the changepassword form?</p>

<p>Please help me!
Thanks in advance!</p>
