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 variables (WinForms)

Global variables (WinForms)

Scheduled Pinned Locked Moved C#
csharpwinformshelptutorialquestion
4 Posts 3 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
    benqazou
    wrote on last edited by
    #1

    Hi, I have developped no more Winforms applications since quite long. I can't see how to create "global variables or objects" that would be shared among all the winforms? In the webforms I was used to Session variables, but with winforms..? Any clue to do the same? Or in message driven way? Any help is welcome. Thanks a lot.

    R L 3 Replies Last reply
    0
    • B benqazou

      Hi, I have developped no more Winforms applications since quite long. I can't see how to create "global variables or objects" that would be shared among all the winforms? In the webforms I was used to Session variables, but with winforms..? Any clue to do the same? Or in message driven way? Any help is welcome. Thanks a lot.

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You could make your "global" variables members of a singleton Globals class that's accessible by all the forms in your application. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • B benqazou

        Hi, I have developped no more Winforms applications since quite long. I can't see how to create "global variables or objects" that would be shared among all the winforms? In the webforms I was used to Session variables, but with winforms..? Any clue to do the same? Or in message driven way? Any help is welcome. Thanks a lot.

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        I accidentally deleted your email before reading it. You're better off posting a reply to a note instead of emailing the author. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        1 Reply Last reply
        0
        • B benqazou

          Hi, I have developped no more Winforms applications since quite long. I can't see how to create "global variables or objects" that would be shared among all the winforms? In the webforms I was used to Session variables, but with winforms..? Any clue to do the same? Or in message driven way? Any help is welcome. Thanks a lot.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You can create a static class with static instance variables, or consts, whichever works for you. public static class MyGlobals{ public static int MAX = 10; public static string HW = "Hello World"; } Done!

          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