Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

return true false in C# window application

Posted on 2009-06-30
2
Medium Priority
?
346 Views
Last Modified: 2012-05-07
I have a login screen, license agreement screen, and main screen on my window application. I want the user click the accept button on the license agreement screen after login and then be able to see the main screen. Otherwise the application will shut down.

Can anyone tell me how to do that in C#?
0
Comment
Question by:tommychiu
[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 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24750312
inside your license form, under the Accept button click event (doubleclick the button to view the click event) you can add the following line:

this.Close();  // close the current form (you can also use this.Hide() instead)
under the Cancel (or Not Accept) button, you can put the following line:

Application.Exit();  // end the application
that should do the trick.

-- Abel --
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 24750494
Set the DialogResult() Property of your License form based on whether the user accepted or not:

            // inside the License form:
            this.DialogResult = DialogResult.OK; // <-- if user accepts agreement
            // < or >
            this.DialogResult = DialogResult.Cancel; // <-- if user declines agreement

Then, when you display your license form, use ShowDialog() like this:

            License lic = new License();
            if (lic.ShowDialog() == DialogResult.Cancel)
            {
                Application.Exit();
            }

            // ...continue with loading your main form...
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.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

730 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