private void Form1_Load(object sender, EventArgs e) { txtCmd.Text = "68 01 fe 68 00 06 49 bf d7 0d"; foreach (string port in SerialCom.GetPortNames()) { cbPortName.Items.Add(port); } string[] bauds = new string[] { "9600", "19200", "115200" }; foreach (string baud in bauds) { cbBaudRate.Items.Add(baud); } foreach (string name in Enum.GetNames(typeof(Parity))) { cbParity.Items.Add(name); } for (int i = 5; i < 9; i++) { cbDataBits.Items.Add(i); } foreach (string name in Enum.GetNames(typeof(StopBits))) { cbStopBits.Items.Add(name); } cbBaudRate.SelectedIndex = 0; cbDataBits.SelectedIndex = 3; cbParity.SelectedIndex = 0; if (cbPortName.Items.Count > 0) { cbPortName.SelectedIndex = 0; } cbStopBits.SelectedIndex = 1; }