-
August 23rd, 2013, 12:50 PM
#1
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'??
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
-
August 23rd, 2013, 03:04 PM
#2
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?
-
August 23rd, 2013, 03:09 PM
#3
Re: DialogResult does not default to None?
Indeed I was looking at system.windows.forms.button.dialogresult
I zeroed in non system.windows.forms.dialogresult instead and notice that there is no default documented so. . I suppose I'll need to assume the default is Cancel.
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
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.
Code:
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2
Dim dr As New DialogResult
dr = frm.ShowDialog()
Debug.Print(dr.ToString) ' defaults to Cancel ??
End Sub
End Class
Last edited by NigelTunney; August 23rd, 2013 at 03:22 PM.
Reason: Additional info
-
August 25th, 2013, 03:48 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|