How to reference two forms with each other in C#


Sajjad Arif Gul - January 11, 2016 - 0 comments

This C# Example in Windows Form Application Program shows how to reference form2 in other form1. This C# tutorial is easy to Understand. Referencing in C# programming. How to show form1 on clicking on button on form2 using referencing.

Objective :

How to make two forms reference each other in C#?

Solution:

Coding on Form1:


We have to create an object form form2 on form1’s initializing event.

Coding on Form2:


In form2 we are making form1 its parent form so it will be referenced in form2.

Output:

Hence, when we start the app, form2 will be shown with two buttons. On button2 click event, the form1 will be visible & clicking on Button2 will hide form1.
Author avatar

Sajjad Arif Gul

http://sajjadgul.com
Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts

Post a Comment

Your email address will not be published. Required fields are marked *