Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

return true false in C# window application

Posted on 2009-06-30
2
Medium Priority
?
360 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

772 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