private void Form1_Load(object sender, EventArgs e) { //Get a list of serial port names. string[] ports = SerialPort.GetPortNames(); //Add ports to the dropdown cboxSerialPort.Items.AddRange(ports); //Saved COM port string savedCOMPort = Properties.Settings.Default.COMPort; //If there is a saved com port, use it if (savedCOMPort != null) { //Make saved com port active cboxSerialPort.SelectedText = savedCOMPort; } //Saved auto connect bool savedAutoConnect = Properties.Settings.Default.AutoConnect; //Make saved auto connect setting active cboxAutoConnect.Checked = savedAutoConnect; //Make saved server URL setting active txtServerURL.Text = Properties.Settings.Default.ServerURL; txtApiKey.Text = Properties.Settings.Default.ApiKey; cboxBdRate.Text = Properties.Settings.Default.BdRate; //Init serial connection class handleSerial = new HandleSerial(); //Pass through process bar handleSerial.toolStripProgressBar = toolStripProgressBar; //Pass through status log window handleSerial.txtStatusLog = txtStatusLog; //Pass through connect button handleSerial.btnConnect = btnConnect; //Pass through form handleSerial.form1 = this; //If auto connect specified when loading if (cboxAutoConnect.Checked == true) { //Attempt to start start(); } }