Click here to Skip to main content
15,887,979 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello all
i have a user control to check accessibility for entering users to program.
if id and pass is wrong,nothing happend.
if user enter the correct id and password,the main form will show bt show dialog:
C#
form1 frm=new form1();
frm.showDialog();

but user control still is open.how to close that after loading main form?

Regards
Posted
Updated 25-Aug-12 12:43pm
v2
Comments
Kenneth Haugland 25-Aug-12 18:49pm    
This.Close?
FM7 25-Aug-12 19:00pm    
this.close() not work

try stop the thread about 2 second and then close the form >> (use this code) :
C#
System.Threading.Thread.Sleep(2000);
this.Close();
 
Share this answer
 
v2
Hi,

You said that you have userControl and i think this userControl is for Login functionality. You must have added this userControl in one of your Windows Form. You should not call close method inside userControl. instead you need to write closing function in your form that containing userControl.

You need to create one delegate and that delegate will call the close method of your Form when you succeeded with userControl login.

Hope you got idea,
Thanks
-Amit Gajjar
 
Share this answer
 
In login usercontrol
after you show new form
use this command
C#
this.parentForm.close(); 
//here 'this'=your login usercontrol, 
//'parentForm' is window form inside which you have paste your usercontrol

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900