原来是在combobox的collection属性中手打串口名称,现在发现可以调用serialport中的方法自动获取PC上所有的串口
//获取当前PC机上的所有串口 nice methods to browse all available ports;
string[] ports = SerialPort.GetPortNames();
//将获得的所有串口绑定到combobox控件 add all port names to the comboBox;
foreach (string port in ports)
{
ComboBox_ports.Items.Add(port);
}
不过这么写所显示的串口名称顺序不一定对