|
-
May 12th, 2009, 03:24 PM
#1
Thread Starter
New Member
[RESOLVED] Handling dialog box buttons
I have code that pops up a dialog box and waits for either the OK or Cancel button to be clicked. I am trying to figure out how to get and use the repsonse from dialog box. If the user clicks OK, I want the rest of the code to execute normally (it already does this by default). If the user clicks Cancel, I want to skip the rest of the code. I was assuming OK would return TRUE and Cancel would return FALSE, but that apparently is not correct. How do I figure out whether OK or Cancel was clicked?
Code:
If Not MapCheck() = "" Then
DiaError.TextBoxErr.Text = MapCheck()
If Not DiaError.ShowDialog() Then 'show dialog box and evaluate output
GoTo breakme 'if Cancel is clicked
End If
End If
' Rest of code
-
May 12th, 2009, 03:35 PM
#2
Re: Handling dialog box buttons
Instead of:
Code:
If Not DiaError.ShowDialog() Then 'show dialog box and evaluate output
GoTo breakme 'if Cancel is clicked
End If
use this instead:
Code:
Select Case DiaError.ShowDialog() 'test the dialogresult
Case OK 'edit this for the proper variable
Case Cancel 'edit this for the proper variable
End Select
-
May 12th, 2009, 03:44 PM
#3
Addicted Member
Re: Handling dialog box buttons
 Originally Posted by j-aero
I have code that pops up a dialog box and waits for either the OK or Cancel button to be clicked. I am trying to figure out how to get and use the repsonse from dialog box. If the user clicks OK, I want the rest of the code to execute normally (it already does this by default). If the user clicks Cancel, I want to skip the rest of the code. I was assuming OK would return TRUE and Cancel would return FALSE, but that apparently is not correct. How do I figure out whether OK or Cancel was clicked?
Code:
If Not MapCheck() = "" Then
DiaError.TextBoxErr.Text = MapCheck()
If Not DiaError.ShowDialog() Then 'show dialog box and evaluate output
GoTo breakme 'if Cancel is clicked
End If
End If
' Rest of code
Here's what I did to confirm clearing all nodes in a TreeView...
vb.net Code:
Dim ConfirmClear As DialogResult ConfirmClear = MessageBox.Show("Are you sure that you wish to clear all events?", "Confirm Clear Play Sequence", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) If ConfirmClear = DialogResult.Yes Then tvwPlaySequence.Nodes.Clear() End If
Adapt for your situation.
PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
Help Files: HelpMaker · Dr. Explain · Create Icons: IcoFX
"Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54
-
May 13th, 2009, 07:45 AM
#4
Thread Starter
New Member
Re: Handling dialog box buttons
Thanks. I used Campion's recommendation.
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
|