How to Close form on click of the button using C#.Net - Programming Interview Questions



In this article i will tell you how to close Form on click of the button using C#.Net.


In the Previous articles i explained how to update record into access database using vb.nethow to delete record from access database using vb.nethow to add namespace in vb.netredirect to page according to role while login in, how to open form on click of the button using and many more about C#.Net.

Step 1.

Add Form to your project and Name it as "Form1.cs".

Step 2.

Add another form and name is as "Form2.cs".

Step 3.

Open Form1 and Drag and Drop Button Control on Form1.

Here what we will do is on clicking on the button we will close form 2.

Step 4.

Double click on Button control.

Step 5.

Write the below code there on click event of the button.

Form2 op = new Form2();


Created object of Form2 and use Close() method to Close Form2.

If you want to close current Form. You can use following code.

Give your Valuable Comments.
comments powered by Disqus
Follow me on twitter
About Me
Harpreet Singh
I began programming with C++ when i was 17. Then at the middle of my study .NET came. Then I began to read C# and VB.NET. By the time i learnt SQL and ASP.NET, and developed some websites such as news portals that are active now. Currently i am running my own Software company.
More Articles