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. Problem with MdiParent-MdiChildren forms

Problem with MdiParent-MdiChildren forms

Scheduled Pinned Locked Moved C#
helpquestioncsharpsalestutorial
5 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.
  • N Offline
    N Offline
    Nine_
    wrote on last edited by
    #1

    Hi all I’m having 2 problems in C# now. 1. I have a MDIParent form which loads the login form in the form_load event. From there I if the user login successfully, I want to enable all menu items on the menu bar. If the login is fail, I want to disable some menu items there too. This means I want to enable/disable a MdiParent’s element from a child form, please help me how to do that. 2. From question 1, when I want to open a form from the menu, I create an object then just show it like this. frmCustomer frmCus=new frmCustomer(); frmCus.MdiParent=this; frmCus.Show(); But the problem is while a Customer form is opening, when the Customer menu is clicked, it creates another Customer form for me. Is there any way to check weather the form is shown or not before showing it?

    D 1 Reply Last reply
    0
    • N Nine_

      Hi all I’m having 2 problems in C# now. 1. I have a MDIParent form which loads the login form in the form_load event. From there I if the user login successfully, I want to enable all menu items on the menu bar. If the login is fail, I want to disable some menu items there too. This means I want to enable/disable a MdiParent’s element from a child form, please help me how to do that. 2. From question 1, when I want to open a form from the menu, I create an object then just show it like this. frmCustomer frmCus=new frmCustomer(); frmCus.MdiParent=this; frmCus.Show(); But the problem is while a Customer form is opening, when the Customer menu is clicked, it creates another Customer form for me. Is there any way to check weather the form is shown or not before showing it?

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You need to pass the current instance of your parent form to the LoginForm. This way:

      LoginForm frmLogin = new LoginForm(this);

      While the constructor for LoginForm will be:

      public LoginForm(MDIparent frmParent)
      {
      this.Parent=frmParent;
      }

      This way you will be able to access all the controls of the parent form. For your second problem, Application.OpenForms collection is there to help you. If the CustomerForm is already in the collection, just set Focus to it, otherwise create a new instance of it and show.

      जय हिंद Rajdeep.Net[^] is NOT from India. Proof.[^]

      N 1 Reply Last reply
      0
      • D dan sh

        You need to pass the current instance of your parent form to the LoginForm. This way:

        LoginForm frmLogin = new LoginForm(this);

        While the constructor for LoginForm will be:

        public LoginForm(MDIparent frmParent)
        {
        this.Parent=frmParent;
        }

        This way you will be able to access all the controls of the parent form. For your second problem, Application.OpenForms collection is there to help you. If the CustomerForm is already in the collection, just set Focus to it, otherwise create a new instance of it and show.

        जय हिंद Rajdeep.Net[^] is NOT from India. Proof.[^]

        N Offline
        N Offline
        Nine_
        wrote on last edited by
        #3

        Thank you for your quick reply. It's very helpful for me, but can you give me more where to put Application.OpenForms in?

        D 1 Reply Last reply
        0
        • N Nine_

          Thank you for your quick reply. It's very helpful for me, but can you give me more where to put Application.OpenForms in?

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          Inside the CustomerMenu click event.

          ClickEvent:

          if CustomerForm is open:

          just set the focus on it

          else:

          Create it

          End

          जय हिंद Rajdeep.Net[^] is NOT from India. Proof.[^]

          N 1 Reply Last reply
          0
          • D dan sh

            Inside the CustomerMenu click event.

            ClickEvent:

            if CustomerForm is open:

            just set the focus on it

            else:

            Create it

            End

            जय हिंद Rajdeep.Net[^] is NOT from India. Proof.[^]

            N Offline
            N Offline
            Nine_
            wrote on last edited by
            #5

            I got it, thank you very much.

            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