serialPort1.PortName = comboBox1.SelectedItem.ToString();
serialPort1.BaudRate = Convert.ToInt32(comboBox2.SelectedItem.ToString());
switch (comboBox3.SelectedIndex)
{
case 0:
serialPort1.Parity = Parity.None;
break;
case 1:
serialPort1.Parity = Parity.Odd;
break;
case 2:
serialPort1.Parity = Parity.Even;
break;
case 3:
serialPort1.Parity = Parity.Mark;
break;
case 4:
serialPort1.Parity = Parity.Space;
break;
}
serialPort1.DataBits = Convert.ToInt32(comboBox4.SelectedItem.ToString());
switch (comboBox5.SelectedIndex)
{
case 0:
serialPort1.StopBits = StopBits.One;
break;
case 1:
serialPort1.StopBits = StopBits.Two;
break;
case 2:
serialPort1.StopBits = StopBits.OnePointFive;
break;
}
serialPort1.Open();