Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Can someone verify these assumptions on dialog boxes?

Can someone verify these assumptions on dialog boxes?

Scheduled Pinned Locked Moved C#
helptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LongRange Shooter
    wrote on last edited by
    #1

    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...

    D Richard DeemingR J 3 Replies Last reply
    0
    • L LongRange Shooter

      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...

      D Offline
      D Offline
      Daaron
      wrote on last edited by
      #2

      try this instead:suss:: VerifyDialog myDialog = new VerifyDialog; if (myDialog.Show()==DialogResult.Yes) { go ahead and do this. } Cheers, Daaron

      L 1 Reply Last reply
      0
      • D Daaron

        try this instead:suss:: VerifyDialog myDialog = new VerifyDialog; if (myDialog.Show()==DialogResult.Yes) { go ahead and do this. } Cheers, Daaron

        L Offline
        L Offline
        LongRange Shooter
        wrote on last edited by
        #3

        :):):) 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...

        1 Reply Last reply
        0
        • L LongRange Shooter

          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...

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4
          • Create a new form.

          • Set the FormBorderStyle to FixedDialog.

          • Add your controls.

          • Set the AcceptButton property of the form to the default button, and the CancelButton 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.

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • L LongRange Shooter

            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...

            J Offline
            J Offline
            James T Johnson
            wrote on last edited by
            #5

            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 -

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups