0

I've been trying to pass a value from a closing form to a form that is about to load.

Let's say I have two forms. When I hide() Form1 the value from a textBox should be carried over to a variable/constructor in Form2 when I Show() it.

My code is in a different laptop and I can't copy it now so I can't post it here. An example would be nice.

1 Answers1

1

To send some value to a other form you can use "where AccommodationInfo is the form you want to open and MName is the value you want to send" this code to open the form and send the value with it.

        AccommodationInfo AI = new AccommodationInfo();
        AI.TextBoxValue = MName;
        AI.Show();

Then in the form that needs to get the value you use "where HouseNameComboBox is the location where the value will be set" this code to get and set the value.

    public string TextBoxValue
    {
        get { return HouseNameComboBox.Text; }
        set { HouseNameComboBox.Text = value; }
    }
Creator
  • 1,502
  • 4
  • 17
  • 30