private void SerialPort_IniInit() { try { st_Serial_Proxy.Baud = Convert.ToInt32(st_ConfigIni.GetProjectInfor2Ini(sysCondigIni, "Serial", "Baud")); st_Serial_Proxy.Comport = st_ConfigIni.GetProjectInfor2Ini(sysCondigIni, "Serial", "Port"); comboBox_ComPort.Text = st_Serial_Proxy.Comport; comboBox_Baud.Text = st_Serial_Proxy.Baud.ToString(); } catch { } }
private void SerialPort_IniInit() { try { int baudIndex = 0; string[] port = System.IO.Ports.SerialPort.GetPortNames();//搜索PC可用的串口号 if (port != null) { comboBox_ComPort.Items.Clear(); foreach (string cName in port) { comboBox_ComPort.Items.Add(cName); if (cName == ComPort) { comboBox_ComPort.SelectedIndex = baudIndex; } baudIndex++; } } Control.CheckForIllegalCrossThreadCalls = false; //波特率 comboBox_Baud.Items.Clear(); foreach (string cName in StringBaud) { comboBox_Baud.Items.Add(cName); } comboBox_Baud.SelectedIndex = 4; st_Serial_Proxy.Baud = Convert.ToInt32(st_ConfigIni.GetProjectInfor2Ini(sysCondigIni, "Motor_Serial", "Baud")); st_Serial_Proxy.Comport = st_ConfigIni.GetProjectInfor2Ini(sysCondigIni, "Motor_Serial", "Port"); comboBox_ComPort.Text = st_Serial_Proxy.Comport; comboBox_Baud.Text = st_Serial_Proxy.Baud.ToString(); } catch { } }