?
Solved

Close a form in a usercontrol

Posted on 2015-01-05
3
Medium Priority
?
181 Views
Last Modified: 2015-01-05
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
Comment
Question by:r3nder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 40531902
Is this what you want?
((Form)this.Parent).Close();
0
 
LVL 6

Author Comment

by:r3nder
ID: 40532039
I tried that and it didnt work - then I cleaned the solution and it worked - go figure :D
0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40532041
thanks Andy
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question