as

Saturday 18 January 2014

How to open the form as a modal dialog box in C#.Net

First let me tell you the meaning of the modal window.

Modal window Definition :

A modal window is a child window that user should work on and close it only after which user can access the parent window.

So if application has one modal window, User will not be able to perform any operation on any controls of the parent window. User must do some operations on the modal child window and when the modal window is closed after the operation is completed, User can work with parent window.

Create a Modal window in C#.Net:

We can create modal window in C# very easily.

Modalwin x = new Modalwin();
x.ShowDialog(this);

Above code will open the modal window x and current window from which we have executed this code will become the parent window.

We can access the parent window members from the modal window class using below code

((ParentForm1)this.Owner)

This is how you can access the parent window instance.






What do you think on this topic? Please express your opinion through comment below

Sponsored Links

Popular Posts

Comments

ShareThis