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. Multy form question

Multy form question

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

    Can someone help me with multy form communication ? The question is: If I have 2,3,more... forms visible how can form number 1 send some data (for exmaple: move progress bar) on Form number 2,3,4,more... ?? Sending varibales from one form to another,sharing resources and stuff ?? :laugh: "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

    S I 2 Replies Last reply
    0
    • J Jasper4C

      Can someone help me with multy form communication ? The question is: If I have 2,3,more... forms visible how can form number 1 send some data (for exmaple: move progress bar) on Form number 2,3,4,more... ?? Sending varibales from one form to another,sharing resources and stuff ?? :laugh: "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

      S Offline
      S Offline
      Saikat Sen
      wrote on last edited by
      #2

      There is more than one way to do this. 1/ You can have a singleton object in your system that will hold data (for example ints) through which these forms will communicate. 2/ If you have a singleton, one form could fire an event when it wishes to communicate data, the singleton have an event handler, and then invoking a method on form2 to set the variable.

      1 Reply Last reply
      0
      • J Jasper4C

        Can someone help me with multy form communication ? The question is: If I have 2,3,more... forms visible how can form number 1 send some data (for exmaple: move progress bar) on Form number 2,3,4,more... ?? Sending varibales from one form to another,sharing resources and stuff ?? :laugh: "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

        I Offline
        I Offline
        I G 198
        wrote on last edited by
        #3

        1. Make the progress bar Public. 2. To the form number 1 give the references to forms 2,3,4... 3. Use the reference to move progress bar. The refenrences can be passed as a constructor parameter or kept as a static array.

        J 1 Reply Last reply
        0
        • I I G 198

          1. Make the progress bar Public. 2. To the form number 1 give the references to forms 2,3,4... 3. Use the reference to move progress bar. The refenrences can be passed as a constructor parameter or kept as a static array.

          J Offline
          J Offline
          Jasper4C
          wrote on last edited by
          #4

          Like this ? //on Form 1 Form frm2 = new MyNamespace.Form2(); frm2.Show(); ++frm2.progressBar1.value; This is what you mean ? "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

          I 1 Reply Last reply
          0
          • J Jasper4C

            Like this ? //on Form 1 Form frm2 = new MyNamespace.Form2(); frm2.Show(); ++frm2.progressBar1.value; This is what you mean ? "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

            I Offline
            I Offline
            I G 198
            wrote on last edited by
            #5

            Yes. This is what I meant. Of course this relates to Windows forms, not Web forms.

            J 1 Reply Last reply
            0
            • I I G 198

              Yes. This is what I meant. Of course this relates to Windows forms, not Web forms.

              J Offline
              J Offline
              Jasper4C
              wrote on last edited by
              #6

              But in this case I have to make progressBar1 on Form2 - static ! public **static** ProgressBar progressBar1; otherwise I can not see it :( "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

              I 1 Reply Last reply
              0
              • J Jasper4C

                But in this case I have to make progressBar1 on Form2 - static ! public **static** ProgressBar progressBar1; otherwise I can not see it :( "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

                I Offline
                I Offline
                I G 198
                wrote on last edited by
                #7

                You can not see it because you use general type to reference your form. Consider the example:

                Form frm1 = new MyFormWithProgressBar();
                frm1.Show();
                frm1.progressBar1.Value++; // this is error

                The correct code is:

                MyFormWithProgressBar frm1 = new MyFormWithProgressBar();
                frm1.Show();
                frm1.progressBar1.Value++; // this will work

                Sorry that I have not noticed that mistake in your previous post.

                J 1 Reply Last reply
                0
                • I I G 198

                  You can not see it because you use general type to reference your form. Consider the example:

                  Form frm1 = new MyFormWithProgressBar();
                  frm1.Show();
                  frm1.progressBar1.Value++; // this is error

                  The correct code is:

                  MyFormWithProgressBar frm1 = new MyFormWithProgressBar();
                  frm1.Show();
                  frm1.progressBar1.Value++; // this will work

                  Sorry that I have not noticed that mistake in your previous post.

                  J Offline
                  J Offline
                  Jasper4C
                  wrote on last edited by
                  #8

                  Nice.. 10x [Do you know how to make form transperent / non-standart shape ?] "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

                  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