ComboBox默认数据绑定
界面

代码展示
public FrmMain()
{
InitializeComponent();
string[] portList = SerialPort.GetPortNames();
if(portList.Length > 0) {
this.cmb_Port.Items.AddRange(portList);
this.cmb_Port.SelectedIndex = 0;
}
for (int i = 1; i < 11; i++)
{
this.cmb_DevAdd.Items.Add(i);
}
this.cmb_DevAdd.SelectedIndex = 0;
this.cmb_Lang.DataSource = new string[] { "简体中文", "English" };
}

浙公网安备 33010602011771号