{
this.serialPort1.PortName = boBox1.SelectedItem.ToString(); }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) {
this.serialPort1.BaudRate = Convert.ToInt32(boBox2.SelectedItem); }
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) {
switch (boBox3.SelectedItem.ToString()) {
case "None":
this.serialPort1.Parity = Parity.None; break; case "Even":
this.serialPort1.Parity = Parity.Even; break; case "Odd":
this.serialPort1.Parity = Parity.Odd; break;
default: this.serialPort1.Parity = Parity.None; break; } }
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) {
this.serialPort1.DataBits = Convert.ToInt16(boBox4.SelectedItem); }
private void comboBox5_SelectedIndexChanged(object sender, EventArgs e) {
switch (Convert.ToInt16(boBox5.SelectedItem)) {
case 1:
this.serialPort1.StopBits = StopBits.One; break; case 2:
this.serialPort1.StopBits = StopBits.Two; break; default:
this.serialPort1.StopBits = StopBits.One; break; } }
private void Form1_Load(object sender, EventArgs e) {
#region ------以下各赋值语句都会触发相应的SelectedIndexChanged事件,同时会对串口进行初始化设------
boBox1.SelectedItem = boBox1.Items[3]; //"COM4";
boBox2.SelectedItem = boBox2.Items[3]; //9600; boBox3.SelectedItem = boBox3.Items[0]; //8; boBox4.SelectedItem = boBox4.Items[0];//Parity.None;
boBox5.SelectedItem =boBox5.Items[0];///StopBits.One
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新教学研究DSP课程设计(19)全文阅读和word下载服务。
相关推荐: