Close/OK Form Button

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

I have several questions, the first one is what event do you write to when
someone clicks the close or "X" button in the upper right-hand corner of the
screen...is it the OnClosed() event?

Second, how can I put an "OK" button in the upper right-hand corner of a
form since I don't see a property to set this like in eMbedded Visual Basic?
I'm using C# so maybe that's why, but I have no idea. If there is a way,
what event do I use to handle the click of the "OK" button?

Thanks for the help
 
The event is Closing. The parameter "e" has Cancel property that can be set
to false to prevent closing

The OK vs X is controlled by Minimize property of the form (true means X),
except for the forms displayed using ShowDialog() - those always have OK
 
To display the OK button (which closes the app instead of smart mimizing it
which the X does) do the following:

Me.MinimizeBox = False

or

this.MinimizeBox = false;

in the constructor of your form. For more information, see "Pocket PC Form
Styles" in the Windows Forms section of the .NET Compact Framework
QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/

- Bruce Hamilton
Microsoft
 
Back
Top