Solved

return true false in C# window application

Posted on 2009-06-30
2
296 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
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 85

Accepted Solution

by:
Mike Tomlinson earned 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now