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. Global access

Global access

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 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.
  • B Offline
    B Offline
    B I Khan
    wrote on last edited by
    #1

    HELP REQD. Trying to move from VB6 to C# (v2003) I made a MDI application which calls up Child forms from the main Menu of the MDI form. The menu Item is disabled when selected and the Child form shows up. It works fine till this point with the following code. mnuMHlagreement is the Name of the menu Item and frmLicence is the Child form. private void mnuMHlagreement_Click(object sender, System.EventArgs e) { showForm(new frmLicence(), mnuMHlagreement); } private void showForm(Form formName, MenuItem menuName) { // Disable Menu Item menuName.Enabled=false; // Set the Parent Form of the Child window. formName.MdiParent = this; // Set Background Colour. formName.BackColor = cFrmBClr; // Display the new form. formName.Show(); } Now I want to enable the menu Item on the parent MDI form when the Child form is closed, which so far I have not been able to do. I am sure almost all of you out there know how it is done. So please let me know too. Also in VB6 we could add Modules where all the Global declarations, etc. were made. In the above example cFrmBClr is a variable which holds the COlor selected at runtime from a ColorDialog on the MDI form. How do I make this a Global variable so that it can be accessed from any form. I THANK YOU IN ANTICIPATION OF YOUR VALUABLE HELP. BIK

    C 1 Reply Last reply
    0
    • B B I Khan

      HELP REQD. Trying to move from VB6 to C# (v2003) I made a MDI application which calls up Child forms from the main Menu of the MDI form. The menu Item is disabled when selected and the Child form shows up. It works fine till this point with the following code. mnuMHlagreement is the Name of the menu Item and frmLicence is the Child form. private void mnuMHlagreement_Click(object sender, System.EventArgs e) { showForm(new frmLicence(), mnuMHlagreement); } private void showForm(Form formName, MenuItem menuName) { // Disable Menu Item menuName.Enabled=false; // Set the Parent Form of the Child window. formName.MdiParent = this; // Set Background Colour. formName.BackColor = cFrmBClr; // Display the new form. formName.Show(); } Now I want to enable the menu Item on the parent MDI form when the Child form is closed, which so far I have not been able to do. I am sure almost all of you out there know how it is done. So please let me know too. Also in VB6 we could add Modules where all the Global declarations, etc. were made. In the above example cFrmBClr is a variable which holds the COlor selected at runtime from a ColorDialog on the MDI form. How do I make this a Global variable so that it can be accessed from any form. I THANK YOU IN ANTICIPATION OF YOUR VALUABLE HELP. BIK

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you want a parent form to do something based on the action of a child, the best way is to set up a delegate, so that a method in the main form gets called by your child form code, without the two being tightly coupled. 'delegate event C# site:msdn.microsoft.com' is the google string to get the info you need here.

      us_bik wrote:

      How do I make this a Global variable so that it can be accessed from any form.

      .NET, wisely, does not allow the hackery of global variables. If you need something to be visible, make it a static property on a class, then you can access it from anywhere with className.PropertyName. Christian Graus - Microsoft MVP - C++

      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