tags:

views:

33

answers:

2

Hi,

Ho do I open a winform within another winform and disable the parent?

I want to create a log in. So I create a form and this form open the log in form, but I want to disable the one that opens the log in form.

thanks

+2  A: 

From the parent form, use the ShowDialog method of the child form, optionally passing a reference to the parent form:

ChildForm x = new ChildForm();
x.ShowDialog(this);
Jon B
But if hit the close button of the login the parent will show
roncansan
Yes, as soon as you close the login form the parent form will appear. Use the DialogResult value that is returned from ShowDialog to determine if the login was successful or cancelled. If it was cancelled, you can take whatever action you like (like closing the program).
Jon B
+1  A: 

Why don't you open your logon form modally, like this:

form.ShowDialog();

This way the user can't do anything with the parent form that launched the logon screen.

Jay Riggs