Passing a value from a main form to a subform in C# – Programming, Pseudocode Example, C# Programming Example
C#

Passing a value from a main form to a subform in C#

In order for a form change to be noticed by the MainForm, it must offer interfaces.
It is not easy for beginners to see the connections.

Here is an example that illustrates how, for example, a text that you enter in the main form in a TextBox can be transferred to another form:

First we instantiate the SubForm Global in the MainForm and display it in the MainForm load event:

Form 1 Code

Then we insert a public method in the subform that outputs a MessageBox with passed parameters.

Form 2 Code

TextChanged Event

Now, You can see how the subform outputs a MessageBox with passed TextBox content.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: