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. Closing a form issue

Closing a form issue

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

    Hi all, I have a form that when loaded begins to write to a serial port. On closing the form, the serial port is closed. When I click the "X" button to close the form, the form stays open, but the data from the serial port discontinues. However, to get the form to actually close, it will not do so until I right click the form's pane in the taskbar. Not sure why this would be happening....

    private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
    {
    if (_serialPort.IsOpen) _serialPort.Close();

        }
    
    P A 2 Replies Last reply
    0
    • M mprice214

      Hi all, I have a form that when loaded begins to write to a serial port. On closing the form, the serial port is closed. When I click the "X" button to close the form, the form stays open, but the data from the serial port discontinues. However, to get the form to actually close, it will not do so until I right click the form's pane in the taskbar. Not sure why this would be happening....

      private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
      {
      if (_serialPort.IsOpen) _serialPort.Close();

          }
      
      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Set a breakpoint on the if and debug.

      1 Reply Last reply
      0
      • M mprice214

        Hi all, I have a form that when loaded begins to write to a serial port. On closing the form, the serial port is closed. When I click the "X" button to close the form, the form stays open, but the data from the serial port discontinues. However, to get the form to actually close, it will not do so until I right click the form's pane in the taskbar. Not sure why this would be happening....

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
        if (_serialPort.IsOpen) _serialPort.Close();

            }
        
        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Is your form modal? The x button behaviour may vary based on this. See here.

        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