0

I want to pass texbox username value to another form name FormPassword. I try this code in FormPassword.cs:

    string strUserName;

    public string passvalue
    {
        get { return strUserName; }
        set { strUserName = value; }

    }

in first form from which I want to get value of username.text

FormPassword frm = new FormPassword(); frm.passvalue = username.Text;

but it give Nothing.

meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
Avais
  • 5
  • 4
  • 1
    Possible duplicate of [Send values from one form to another form](http://stackoverflow.com/questions/1559770/send-values-from-one-form-to-another-form) – Gilad Green Jul 17 '16 at 08:00
  • Your approach seems to be fine. You need to show more of your code. How are you reading the value inside `FormPassword ` ? – Zein Makki Jul 17 '16 at 08:03
  • code for reading value `string uname; uname = strUserName;` – Avais Jul 17 '16 at 08:05
  • when i am debugging `FormPassword frm = new FormPassword();` `frm.passvalue = username.Text;` , username's can't assign value to `frm.passvalue` – Avais Jul 17 '16 at 08:09
  • Possible duplicate of [Passing TextBox's text to another form in C#?](http://stackoverflow.com/questions/11165537/passing-textboxs-text-to-another-form-in-c) – Almir Vuk Jul 17 '16 at 09:55
  • it may b duplicate but i have tried that , but its not working for me – Avais Jul 17 '16 at 10:03
  • It _is_ a duplicate. And there are at least three methods in that answer. One of them _will work_ for you, if you can code it correctly. – DonBoitnott Jul 18 '16 at 11:47

1 Answers1

0

create parameterized constructor of second form and then pass the value to that form.

yatin parab
  • 174
  • 6