-2

I have Login form where textBox1 contain user ID.I'm trying to use entered ID in another windows form.In LOGIN Form strvalue have ID, but in Another Form strvalue is empty. Sorry for dumb question.

code - LOGIN Form:

public static string strvalue = "";

private void button22_Click(object sender, EventArgs e)       
{       
    strvalue = textBox1.Text;   
}

code Another Form:

LOGIN LF = new LOGIN();

MessageBox.Show(LF.strvalue);
awh112
  • 1,466
  • 4
  • 22
  • 34
Pepoo
  • 7
  • 2
  • 2
    you never showed (display) the other form to the user. I would totally expect the value to be empty – Steve Jun 06 '18 at 17:11
  • OP you should go read more about OOP and events. once you got a deeper understanding you will figure this out easily. – Steve Jun 06 '18 at 17:14
  • [Duplicate 1](http://stackoverflow.com/questions/3062575/) [duplicate 2](http://stackoverflow.com/questions/7800731/) [duplicate 3](http://stackoverflow.com/questions/17032484/) [duplicate 4](http://stackoverflow.com/questions/17836398/) [duplicate 5](http://stackoverflow.com/questions/25316230/) [duplicate 6](http://stackoverflow.com/questions/29092707/) ... – Dour High Arch Jun 06 '18 at 17:17

1 Answers1

0

You are not handling events and flow control appropriately. Like steve said, it is necessary for you to display your login form in response to a particular event or function call. Afterwards, you can access public methods of the current running instance for LOGIN Form.

You can also take a look at this answer to a similar question

Koji D'infinte
  • 1,309
  • 12
  • 20