Solved

return true false in C# window application

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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