If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

DialogResult does not default to None?

VB.NET 2010, Framework 3.5

All the documentation I see says that the DialogResult's default value is None

Return Values:
One of the System.Windows.Forms.DialogResult values. The default value is None.

The problems I'm seeing. . I open a form via ShowDialog(), the form I open does NOT set a DialogResult value anywhere, it seems no matter how I close the dialog the returning DialogResult is always 'Cancel' not 'None'. Why is it documented to default to 'None' when it seems that the default is 'Cancel'??

Re: DialogResult does not default to None?

You're confusing the Button's DialogResult property with the Form's ShowDialog return value.
The ShowDialog's return value will be the DialogResult of the Button clicked - if you clicked with the 'x' on the upper right, then according to ShowDialog's documention, the return value is 'Cancel'. If you clicked on one of your buttons, what is the value of the button's DialogResult property?

I was hoping to see a documented 'default' return value to know what to look for when a form is closed via <Alt><F4>, by Right Clicking the icon in the task bar and choosing <Close> or Xing our via the top right corner etc.

Re: DialogResult does not default to None?

Originally Posted by NigelTunney

I was hoping to see a documented 'default' return value to know what to look for when a form is closed via <Alt><F4>, by Right Clicking the icon in the task bar and choosing <Close> or Xing our via the top right corner etc.

The FormClosing event can provide info on how the Form is going to be closed. That event passes a FormClosingEventArgs which has a property called CloseReason.