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. Need to make a GUI for reading from serial Port. And using Multiple forms

Need to make a GUI for reading from serial Port. And using Multiple forms

Scheduled Pinned Locked Moved C#
comhardwarehelpquestion
5 Posts 4 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.
  • A Offline
    A Offline
    alfie max15
    wrote on last edited by
    #1

    I am doing a project in which i am trying to read the data that is being sent from my microcontroller to the PC through serial port. I am ok with the serial part (i guess)... I was thinking of making it like, first when i run the program a gui would pop up asking user to select the COM port and other details like handshake, parity, baud rate, etc. And after setting all that when the user presses the START button the current form should close and another form should pop up showing the data being read from the port continously. Is that possible to create multiple forms ???? If possible please help me in doing so....

    M L 2 Replies Last reply
    0
    • A alfie max15

      I am doing a project in which i am trying to read the data that is being sent from my microcontroller to the PC through serial port. I am ok with the serial part (i guess)... I was thinking of making it like, first when i run the program a gui would pop up asking user to select the COM port and other details like handshake, parity, baud rate, etc. And after setting all that when the user presses the START button the current form should close and another form should pop up showing the data being read from the port continously. Is that possible to create multiple forms ???? If possible please help me in doing so....

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      alfie.max15 wrote:

      Is that possible to create multiple forms

      Yes of course it is possible, use winforms or WPF for the UI. Help you - Ok! Do some research and decide on a platform, then get a book on that platform, read the book and do the examples. When you have completed that start your application, when you run across a specific problem come back and we may be able to help you.

      Never underestimate the power of human stupidity RAH

      A 1 Reply Last reply
      0
      • M Mycroft Holmes

        alfie.max15 wrote:

        Is that possible to create multiple forms

        Yes of course it is possible, use winforms or WPF for the UI. Help you - Ok! Do some research and decide on a platform, then get a book on that platform, read the book and do the examples. When you have completed that start your application, when you run across a specific problem come back and we may be able to help you.

        Never underestimate the power of human stupidity RAH

        A Offline
        A Offline
        alfie max15
        wrote on last edited by
        #3

        Thanx... I did that... Now what i specifically want is that when i press the button the form2 should pop up but at the same time the form1 should close. i tried... In form1

        private void Start_Click (object sender, EventArgs e)
        {
        secondForm.Show();
        this.Close ();

            }
        

        but what happened was that the form2 will open and both form 1 and form2 get closed. i thought only form1 will get close as i had called this from form1

        F 1 Reply Last reply
        0
        • A alfie max15

          Thanx... I did that... Now what i specifically want is that when i press the button the form2 should pop up but at the same time the form1 should close. i tried... In form1

          private void Start_Click (object sender, EventArgs e)
          {
          secondForm.Show();
          this.Close ();

              }
          

          but what happened was that the form2 will open and both form 1 and form2 get closed. i thought only form1 will get close as i had called this from form1

          F Offline
          F Offline
          Freak30
          wrote on last edited by
          #4

          If Form1 is the main form, the application will end on closing it. You could create 2 additional forms, make the main form invisible and start the second form (for taking the parameters) in the load event of the main form. Also you should open it with ShowDialog() to create a modal form. On pressing the button confirm you set the DialogResult to something specific, so you get this value as return value from ShowDialog() after closing your parameter form. Then you can open the third form showing the data. Another approach would be to transfer the logic of opening the second dialog to the program class, opening the second form if the main form was closed using confirm and exit tha pplication only if the second form is closed or the main form is closed in another way than pressing confirm.

          The good thing about pessimism is, that you are always either right or pleasently surprised.

          1 Reply Last reply
          0
          • A alfie max15

            I am doing a project in which i am trying to read the data that is being sent from my microcontroller to the PC through serial port. I am ok with the serial part (i guess)... I was thinking of making it like, first when i run the program a gui would pop up asking user to select the COM port and other details like handshake, parity, baud rate, etc. And after setting all that when the user presses the START button the current form should close and another form should pop up showing the data being read from the port continously. Is that possible to create multiple forms ???? If possible please help me in doing so....

            L Offline
            L Offline
            lukeer
            wrote on last edited by
            #5

            I vote for your "2nd form" becoming the main form. It's what you actually want to see anyway. The main form can create and show what now is you "1st form". But it essentially is just a dialog to set up some properties. So make it just a dialogue that is started by your main form. Additional benefit: Later, you can implement a menu, button or whatever control so user can open a connection properties dialogue again, with the same logic you already have (in case user entered wrong parameter, or another controller on another port, or...).

            Ciao, luker

            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