读取本机串口

1.定义一个字符串数组,并将获取到的电脑上串口名字赋值给它。
string[] ArryPort = SerialPort.GetPortNames();
2.将一个组合框的内容清除
cmbPort.Items.Clear();
3。将数组中的值添加到组合框中

for (int i = 0; i < ArryPort.Length; i++)
{
cmbPort.Items.Add(ArryPort[i]);
}

原文地址:https://www.cnblogs.com/aijiao/p/10057382.html