Search code examples
c#.netwinformsuser-controlssplitcontainer

I want to retrieve the sub form values


I have a SplitContainer, and in its right panel I have a Form. I want to retrieve the values of the TextBoxes of the form when I click on a button outside the Form, but inside the panel. How to do it?


Solution

  • May be you are having a UserControl in the Right panel of the SplitContainer.

    In you that userControl class write a public method to get values.

    public string GetValueOfTheTextBox()
    {
        return textBox.Text;
    }
    

    Add the userControl the SplitContainer.

    MyUserControl myUserControl = new MyUserControl();
    //Add this to the splitContainer right panel.
    

    From out side of the MyUserControl class you can call GetValueOfTheTextBox method.

    string text = myUserControl.GetValueOfTheTextBox();