• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Close a form in a usercontrol

I have a form I use to login as a different user - if I click cancel it closes the entire application and not just the form
the form is called from a usercontrol
Forms.Login li = new Forms.Login(); 
public void ShowLogin(string title)
        {
            li.title = title;
            li.ShowDialog();
        }

Open in new window

in the code for the cancel button I am using
((Form)this.TopLevelControl).Close();

Open in new window

like I said - after cancel is selected the entire app closes
what am I not seeing here
0
r3nder
Asked:
r3nder
  • 2
1 Solution
 
AndyAinscowCommented:
Is this what you want?
((Form)this.Parent).Close();
0
 
r3nderAuthor Commented:
I tried that and it didnt work - then I cleaned the solution and it worked - go figure :D
0
 
r3nderAuthor Commented:
thanks Andy
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now