private void Serial_UpdatePortName() { lstSerialComPort.Items.Clear(); foreach (string comport_s in MySerial.FindAllSerialPort()) { lstSerialComPort.Items.Add(comport_s); } if (lstSerialComPort.Items.Count > 0) { lstSerialComPort.SelectedIndex = 0; // this can be modified to preferred default EnableConnectButton(); UpdateToConnectButton(); } else { DisableConnectButton(); UpdateToConnectButton(); } }