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. Another problem with two forms [modified]

Another problem with two forms [modified]

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • M Offline
    M Offline
    mariuszfryta
    wrote on last edited by
    #1

    I have problem with the data. From my main window I click other form is opened and I want to type in some data like alarm time, but I have problem with display it in my main window. I want display it in my label but i don't how to get to that label,and other variables in my main window from my second form?? -- modified at 9:55 Saturday 27th May, 2006 examle I have somethin like this public partial class Form1 : Form { public int a, b, c; public Form1() { InitializeComponent(); } and I want to acces the a,b,c prameters from my form2.

    S 1 Reply Last reply
    0
    • M mariuszfryta

      I have problem with the data. From my main window I click other form is opened and I want to type in some data like alarm time, but I have problem with display it in my main window. I want display it in my label but i don't how to get to that label,and other variables in my main window from my second form?? -- modified at 9:55 Saturday 27th May, 2006 examle I have somethin like this public partial class Form1 : Form { public int a, b, c; public Form1() { InitializeComponent(); } and I want to acces the a,b,c prameters from my form2.

      S Offline
      S Offline
      Sean89
      wrote on last edited by
      #2

      Ok so what you would do is hand these variables to the constructor of your second form: Ex.

      public partial class Form2 : Form
      {

      public int d, e, f;
      public Form2(int a, int b, int c)
      {
      d = a;
      e = b;
      f = c;
      InitializeComponent();
      }

      ...

      public partial class Form1 : Form
      {

      public int a, b, c;
      public Form1()
      {
      InitializeComponent();
      }

      something_OnClick()
      {
      Form2 frm2 = new Form2(a, b, c);
      frm2.ShowDialog();
      }


      M 1 Reply Last reply
      0
      • S Sean89

        Ok so what you would do is hand these variables to the constructor of your second form: Ex.

        public partial class Form2 : Form
        {

        public int d, e, f;
        public Form2(int a, int b, int c)
        {
        d = a;
        e = b;
        f = c;
        InitializeComponent();
        }

        ...

        public partial class Form1 : Form
        {

        public int a, b, c;
        public Form1()
        {
        InitializeComponent();
        }

        something_OnClick()
        {
        Form2 frm2 = new Form2(a, b, c);
        frm2.ShowDialog();
        }


        M Offline
        M Offline
        mariuszfryta
        wrote on last edited by
        #3

        Maybe it's works, but I still don't know how to do this.

        S 1 Reply Last reply
        0
        • M mariuszfryta

          Maybe it's works, but I still don't know how to do this.

          S Offline
          S Offline
          Sean89
          wrote on last edited by
          #4

          What dont you understand?


          M 1 Reply Last reply
          0
          • S Sean89

            What dont you understand?


            M Offline
            M Offline
            mariuszfryta
            wrote on last edited by
            #5

            I don't know how it works. Itried to do it as you wrote, but it doesn't work. mariuszfryta

            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