private void btnClose_Click(object sender, EventArgs e) { int port; port = cbxCOM.SelectedIndex + 1; if (com.CloseComPort()) // close COM port { MessageBox.Show("Close COM" + port.ToString() + ": done!", "Close"); } else { MessageBox.Show("Close COM" + port.ToString() + ": failed!", "Error"); } btnClose.Enabled = false; btnSend.Enabled = false; SwitchEnable(true); }