110,538
社区成员
发帖
与我相关
我的任务
分享
private void Form1_Load(object sender, EventArgs e)
{
string[] ArryPort = SerialPort.GetPortNames();
for (int i = 0; i < ArryPort.Length; i++)
{
selectCom.Items.Add(ArryPort[i]);
}
if (ArryPort.Length > 0)
{
selectCom.SelectedIndex = 0;
}
else
{
MessageBox.Show("当前系统无任何可用串口");
}
List<int> list = new List<int>();
for (int k = 1; k <= 10; k++)
{
list.Add(k);
}
adjustNum.DataSource = list;
}
private void UpdateUIText(string strInfo)
{
if(txtBox1.InvokeRequired)
{
Action<string> _handler = new Action(UpdateUIText);;
txtBox1.Invoke(_handler,strInfo)
}
else
{
txtBox1.Text=strInfo;
}