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. .NET (Core and Framework)
  4. Form Cancel Property paired up with Button DialogResult Property is Diabolical!

Form Cancel Property paired up with Button DialogResult Property is Diabolical!

Scheduled Pinned Locked Moved .NET (Core and Framework)
visual-studiotestingbeta-testingquestionlearning
2 Posts 2 Posters 35 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.
  • B Offline
    B Offline
    Brian L Hughes
    wrote on last edited by
    #1

    I decided to "upgrade" my dialog box forms with Accept and Cancel buttons properties! Now my dialog boxes were more user friendly. A week later I began testing on one of these dialog forms which contained a lot of buttons and content, but I ran into a bit of a pickle. One of the many buttons had a click event coded to open a 2nd level modal dialog and when this 2nd dialog box closed the parent dialog it was invoked from closed as well. I couldn't figure out why for the longest time but luckily found the answer on the www. When you set a form's "Cancel" property to a button the genius behind VS sets that button's "DialogResult" property to DialogResult.Cancel. When the button is clicked no matter what happens inside the buttons click handler the parent form will close with a DialogResult.Cancel. If you copy a Cancel button with DialogResult property set to DialogResult.Cancel and paste it on a form the genius behind VS copies the DialogResult property as well, you now have two buttons with DialogResult.Cancel on your form, no warnings of course, it's what you intended to do! I didn't even know buttons had the "DialogResult" property and that it could be used to automatically close a form, obviously it was there all along but I skimmed past it and never tried to experiment with it. Funny thing is the form's Accept property does not change the OK button's DialogResult property to OK when that button is selected. I suppose this feature helps eliminate the need to code Cancel button click events, but I'm so used to doing it anyway I probably won't bother using it in the future. Any idea when this feature was added? Was it there all along?

    M 1 Reply Last reply
    0
    • B Brian L Hughes

      I decided to "upgrade" my dialog box forms with Accept and Cancel buttons properties! Now my dialog boxes were more user friendly. A week later I began testing on one of these dialog forms which contained a lot of buttons and content, but I ran into a bit of a pickle. One of the many buttons had a click event coded to open a 2nd level modal dialog and when this 2nd dialog box closed the parent dialog it was invoked from closed as well. I couldn't figure out why for the longest time but luckily found the answer on the www. When you set a form's "Cancel" property to a button the genius behind VS sets that button's "DialogResult" property to DialogResult.Cancel. When the button is clicked no matter what happens inside the buttons click handler the parent form will close with a DialogResult.Cancel. If you copy a Cancel button with DialogResult property set to DialogResult.Cancel and paste it on a form the genius behind VS copies the DialogResult property as well, you now have two buttons with DialogResult.Cancel on your form, no warnings of course, it's what you intended to do! I didn't even know buttons had the "DialogResult" property and that it could be used to automatically close a form, obviously it was there all along but I skimmed past it and never tried to experiment with it. Funny thing is the form's Accept property does not change the OK button's DialogResult property to OK when that button is selected. I suppose this feature helps eliminate the need to code Cancel button click events, but I'm so used to doing it anyway I probably won't bother using it in the future. Any idea when this feature was added? Was it there all along?

      M Offline
      M Offline
      Muhammad Mohsin May2024
      wrote on last edited by
      #2

      Hey everyone! We’ve got a new mod menu app for Mobile Legends: Bang Bang that can help you out. It’s called “NP Modz” and “Naruto PH Modz”. You

      np modz can grab the APK file from our site. Stick around to learn more about this app and what it can do.

      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