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. How to use ShowDialog in the click event of menu item

How to use ShowDialog in the click event of menu item

Scheduled Pinned Locked Moved C#
tutorial
3 Posts 2 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.
  • M Offline
    M Offline
    Muhammad Gouda
    wrote on last edited by
    #1

    How to make my form acts as a dialog box when it is called from a menu item. I could do this using Form.ShowDialog() within any event of any control on a form. But when I called this function on the click event of a menu item, I got the following exception:mad:. "Forms that are not top level forms cannot be displayed as a modal dialog. Remove the form from any parent form before calling showDialog"

    Mohamed Gouda Egypt

    J 1 Reply Last reply
    0
    • M Muhammad Gouda

      How to make my form acts as a dialog box when it is called from a menu item. I could do this using Form.ShowDialog() within any event of any control on a form. But when I called this function on the click event of a menu item, I got the following exception:mad:. "Forms that are not top level forms cannot be displayed as a modal dialog. Remove the form from any parent form before calling showDialog"

      Mohamed Gouda Egypt

      J Offline
      J Offline
      JeffPClark
      wrote on last edited by
      #2

      Try: Form.ShowDialog(this); This will create a modal dialog form on top of the main form.

      Jeff Clark Systems Architect JP Clark, INC. Columbus, Ohio

      M 1 Reply Last reply
      0
      • J JeffPClark

        Try: Form.ShowDialog(this); This will create a modal dialog form on top of the main form.

        Jeff Clark Systems Architect JP Clark, INC. Columbus, Ohio

        M Offline
        M Offline
        Muhammad Gouda
        wrote on last edited by
        #3

        Thanks Jeff . It did not work. But you helped me rethinking about my code and discover my fault :doh:. The problem was that I defined the MdiParent property of the dialog form to be this My code was some thing like this. MyDialogForm dialogForm = new MyDialogForm(); dialogForm.MdiParent = this; // This was my fault dialogForm.ShowDialog(); However, Thanks a lot

        Mohamed Gouda Egypt

        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