Can someone verify these assumptions on dialog boxes?
-
It appears that the old VB6 approach of a messageBox function that displayed info, possibly got info, and passed back the info or the button selection does not exist in the Framework. To do a modal dialogBox I need to create my own form and set the AccessibleRole = Dialog. For my buttons, I set DialogResult to the value I want to return. So I guess that I would follow the following steps to create a Verify (yes, no) dialog box: Create a form named Verify. Set the AccessibleRole to Dialog. Define my screen (example: Do you want to do this?) with two buttons, Yes, No. Define DialogResult as No for the No button and Yes for the Yes button. In my main program, I code:
VerifyDialog myDialog = new VerifyDialog; if (myDialog.ShowDialog(this) == DialogResult.Yes) { go ahead and do this. }
Am I on the money or about to toss a handgrenade? Thanks for help. _____________________________________________ I have a tendancy to where my mind on my sleeve
I have a habit of losing my shirt... -
It appears that the old VB6 approach of a messageBox function that displayed info, possibly got info, and passed back the info or the button selection does not exist in the Framework. To do a modal dialogBox I need to create my own form and set the AccessibleRole = Dialog. For my buttons, I set DialogResult to the value I want to return. So I guess that I would follow the following steps to create a Verify (yes, no) dialog box: Create a form named Verify. Set the AccessibleRole to Dialog. Define my screen (example: Do you want to do this?) with two buttons, Yes, No. Define DialogResult as No for the No button and Yes for the Yes button. In my main program, I code:
VerifyDialog myDialog = new VerifyDialog; if (myDialog.ShowDialog(this) == DialogResult.Yes) { go ahead and do this. }
Am I on the money or about to toss a handgrenade? Thanks for help. _____________________________________________ I have a tendancy to where my mind on my sleeve
I have a habit of losing my shirt... -
try this instead:suss:: VerifyDialog myDialog = new VerifyDialog; if (myDialog.Show()==DialogResult.Yes) { go ahead and do this. } Cheers, Daaron
:):):) You were responding as I was updating my post as I was also doing the coding as I was following the message board. Is that multi-tasking or what??? :cool: _____________________________________________ I have a tendancy to where my mind on my sleeve
I have a habit of losing my shirt... -
It appears that the old VB6 approach of a messageBox function that displayed info, possibly got info, and passed back the info or the button selection does not exist in the Framework. To do a modal dialogBox I need to create my own form and set the AccessibleRole = Dialog. For my buttons, I set DialogResult to the value I want to return. So I guess that I would follow the following steps to create a Verify (yes, no) dialog box: Create a form named Verify. Set the AccessibleRole to Dialog. Define my screen (example: Do you want to do this?) with two buttons, Yes, No. Define DialogResult as No for the No button and Yes for the Yes button. In my main program, I code:
VerifyDialog myDialog = new VerifyDialog; if (myDialog.ShowDialog(this) == DialogResult.Yes) { go ahead and do this. }
Am I on the money or about to toss a handgrenade? Thanks for help. _____________________________________________ I have a tendancy to where my mind on my sleeve
I have a habit of losing my shirt...-
Create a new form.
-
Set the
FormBorderStyle
toFixedDialog
. -
Add your controls.
-
Set the
AcceptButton
property of the form to the default button, and theCancelButton
property to the button you want to "click" when you press the "Escape" key. -
For each button, set the
DialogResult
property to the relevant value (DialogResult.Yes
,DialogResult.No
, etc.) -
Use the following:
VerifyDialog myDialog = new VerifyDialog();
DialogResult ret = myDialog.ShowDialog();
if (ret == DialogResult.Yes)
{
// Do it!
}
The
AccessibleRole
property is a red herring - it's related to Accessibility for disabled users. -
-
It appears that the old VB6 approach of a messageBox function that displayed info, possibly got info, and passed back the info or the button selection does not exist in the Framework. To do a modal dialogBox I need to create my own form and set the AccessibleRole = Dialog. For my buttons, I set DialogResult to the value I want to return. So I guess that I would follow the following steps to create a Verify (yes, no) dialog box: Create a form named Verify. Set the AccessibleRole to Dialog. Define my screen (example: Do you want to do this?) with two buttons, Yes, No. Define DialogResult as No for the No button and Yes for the Yes button. In my main program, I code:
VerifyDialog myDialog = new VerifyDialog; if (myDialog.ShowDialog(this) == DialogResult.Yes) { go ahead and do this. }
Am I on the money or about to toss a handgrenade? Thanks for help. _____________________________________________ I have a tendancy to where my mind on my sleeve
I have a habit of losing my shirt...If you are just asking for confirmation you can use the MessageBox class to display a message box (MsgBox in VB6). If you need the user to input something (something beyond clicking a button) then you'll have to use the approach you have now. [edit] Sample code would probably help you :)
MessageBox.Show("Are you sure you want to do this?",
"Are you sure?",
MessageBoxButtons.YesNo
);The Show method returns a DialogResult like you are already using. [/edit] James - out of order -