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. Multiple opennings of same form at a time.

Multiple opennings of same form at a time.

Scheduled Pinned Locked Moved C#
csshelp
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.
  • J Offline
    J Offline
    Janu_M
    wrote on last edited by
    #1

    Hi I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form. If i double click the same row or other row it opens the details of respective row again in a same form. For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting. What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time. Please Help me. Thanks in Advance. Ramu Medida.

    V R R 3 Replies Last reply
    0
    • J Janu_M

      Hi I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form. If i double click the same row or other row it opens the details of respective row again in a same form. For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting. What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time. Please Help me. Thanks in Advance. Ramu Medida.

      V Offline
      V Offline
      Victor Boba
      wrote on last edited by
      #2

      Open the form in modal mode. Form1.ShowDialog. This will keep it from opening another form until this one has been closed. Make sure you call Form1.Dispose after ShowDialog because the memory is not released when using ShowDialog as with other Show methods.

      1 Reply Last reply
      0
      • J Janu_M

        Hi I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form. If i double click the same row or other row it opens the details of respective row again in a same form. For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting. What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time. Please Help me. Thanks in Advance. Ramu Medida.

        R Offline
        R Offline
        RedRummy
        wrote on last edited by
        #3

        Instead of re-creating the child form everytime you double click on the parent form, re-use a single child form, showing or hiding it as appropriate. Before you show the form, you can use a DataView on the child form to show the data you're insterested in.:)

        1 Reply Last reply
        0
        • J Janu_M

          Hi I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form. If i double click the same row or other row it opens the details of respective row again in a same form. For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting. What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time. Please Help me. Thanks in Advance. Ramu Medida.

          R Offline
          R Offline
          Russell Jones
          wrote on last edited by
          #4

          i would use a singleton pattern for the form roughly: public class MyForm:Form { private static MyForm _formInstance; private MyForm() { } public static MyForm GetFormInstance() { if (_formInstance == null) _formInstance = new MyForm(); return _formInstance; } } Hope this helps Russell -- modified at 4:15 Thursday 8th March, 2007

          J 1 Reply Last reply
          0
          • R Russell Jones

            i would use a singleton pattern for the form roughly: public class MyForm:Form { private static MyForm _formInstance; private MyForm() { } public static MyForm GetFormInstance() { if (_formInstance == null) _formInstance = new MyForm(); return _formInstance; } } Hope this helps Russell -- modified at 4:15 Thursday 8th March, 2007

            J Offline
            J Offline
            Janu_M
            wrote on last edited by
            #5

            Thank You Very Much. It is working for me. Once Again Thank You. Ramu Medida.

            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