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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Working on MessageBoxButtons

Working on MessageBoxButtons

Scheduled Pinned Locked Moved C#
csharpdatabasetutorialquestion
4 Posts 3 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.
  • C Offline
    C Offline
    CoderForEver
    wrote on last edited by
    #1

    Hi my friends. I was working on one of my application in C# and i was using the following code

    MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

    after this line of code it comes a messagebox which says "Are you sure" ... and Yes and No buttons ... but I wanted to know which button was pressed ... .. i.e If the user presses yes ... I want to delete some thing from Database ... If not continue as it is ..... Can any body tell me how to operate on this question. Thank you

    L 1 Reply Last reply
    0
    • C CoderForEver

      Hi my friends. I was working on one of my application in C# and i was using the following code

      MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

      after this line of code it comes a messagebox which says "Are you sure" ... and Yes and No buttons ... but I wanted to know which button was pressed ... .. i.e If the user presses yes ... I want to delete some thing from Database ... If not continue as it is ..... Can any body tell me how to operate on this question. Thank you

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      DialogResult result = MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

      if (result == DialogResult.Yes)
      //... do something here
      else if(result == DialogResult.No)
      //... do something here

      C 1 Reply Last reply
      0
      • L Lost User

        DialogResult result = MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        if (result == DialogResult.Yes)
        //... do something here
        else if(result == DialogResult.No)
        //... do something here

        C Offline
        C Offline
        CoderForEver
        wrote on last edited by
        #3

        stancrm wrote:

        if (result == DialogResult.Yes) //... do something here else if(result == DialogResult.No) //... do something here

        I have been trying zis a lot and a lot ... but i didnt use ... this one ..

        stancrm wrote:

        DialogResult result = MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        So tnx a lot ma man ...

        S 1 Reply Last reply
        0
        • C CoderForEver

          stancrm wrote:

          if (result == DialogResult.Yes) //... do something here else if(result == DialogResult.No) //... do something here

          I have been trying zis a lot and a lot ... but i didnt use ... this one ..

          stancrm wrote:

          DialogResult result = MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

          So tnx a lot ma man ...

          S Offline
          S Offline
          SimpleData
          wrote on last edited by
          #4

          This is more tidy I guess.

          if(MessageBox.Show("Are you sure", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
          {
          // Do something...
          }
          else
          {
          // Do something else...
          }

          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