Select to view content in your preferred language

MessageBox always returns OK

1730
1
Jump to solution
08-31-2021 06:18 AM
ghefarm
New Contributor

The defaultResult of MessageBox didn't work for me. It was always 'OK'!

I tried to show a MessageBox with the NONE-Result (or CANCEL) as the defaultRersult:

Arc.MessageBox.Show("msg", "title",MessageBoxButton.OK, someIcon, MessageBoxResult.Cancel/None)
Now even clicking on "X" (up right in the box), the OK was returned!

 


Running Pro 2.7.2

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

The ArcGIS Pro API's MesssageBox.Show method returns the same result as the MessageBox method in .Net.  According to the .Net documentation these are the results that are returned (depending on the type of MessageBox):

Show returns a MessageBoxResult value that specifies which button on a message box a user clicked. MessageBoxButton specifies which buttons are displayed on a message box.

The result value that is returned from a message box depends on what buttons the message box has and how a user closes a message box:

  • On a message box that has an OK button, OK is returned if a user clicks the OK button, clicks the Close button in the title bar, or presses the ESC key.
  • On a message box that has an OK button and a Cancel button, OK is returned if a user clicks the OK button. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.
  • On a message box that has a Yes button and a No button, the Close button in the title bar is disabled. Consequently, Yes is returned if a user clicks the Yes button, and No is returned if a user clicks the No button.
  • On a message box that has a Yes button, a No button, and a Cancel button, Yes is returned if the Yes button is clicked and No is returned if the No button is clicked. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

See: https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult?view=net-5.0 

View solution in original post

0 Kudos
1 Reply
Wolf
by Esri Regular Contributor
Esri Regular Contributor

The ArcGIS Pro API's MesssageBox.Show method returns the same result as the MessageBox method in .Net.  According to the .Net documentation these are the results that are returned (depending on the type of MessageBox):

Show returns a MessageBoxResult value that specifies which button on a message box a user clicked. MessageBoxButton specifies which buttons are displayed on a message box.

The result value that is returned from a message box depends on what buttons the message box has and how a user closes a message box:

  • On a message box that has an OK button, OK is returned if a user clicks the OK button, clicks the Close button in the title bar, or presses the ESC key.
  • On a message box that has an OK button and a Cancel button, OK is returned if a user clicks the OK button. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.
  • On a message box that has a Yes button and a No button, the Close button in the title bar is disabled. Consequently, Yes is returned if a user clicks the Yes button, and No is returned if a user clicks the No button.
  • On a message box that has a Yes button, a No button, and a Cancel button, Yes is returned if the Yes button is clicked and No is returned if the No button is clicked. If a user clicks the Cancel button or the Close button in the title bar, Cancel is returned.

See: https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult?view=net-5.0 

0 Kudos