private void Form1_Load(object sender, EventArgs e) //界面初始化 { GetPrivateProfileString("PortData", "PortName", "COM0", temp, 256, FileName); //读取ini值,默认是COM0 GetPrivateProfileString("BpsData", "Bps", "9600", temp1, 256, FileName); //读取ini值,默认是9600 comboBox_Ports.Text = temp.ToString(); //初始化 comboBox_Bps.Text = temp1.ToString(); //comboBox_Ports.SelectedIndex = 0; //端口默认COM0 //comboBox_Bps.SelectedIndex = 3; //波特率默认9600 button_Close.Enabled = false; serialPort1.DataReceived += SerialPort1_DataReceived; //添加串口接受数据事件 //Control.CheckForIllegalCrossThreadCalls = false; //禁止跨线程审查 bufferChanged += new UpdateBufferEventHandle(HandleBuffer); //将事件处理方法添加到事件中去 tabControl1.SelectedTab = this.tabPage1; //设置默认tabPage InitLight(); //初始化提示灯 }
private void Form1_Load(object sender, EventArgs e) //界面初始化 { GetPrivateProfileString("PortData", "PortName", "COM0", com, 256, FileName); //读取ini值,如果没找到默认是COM0 GetPrivateProfileString("BpsData", "Bps", "9600", bps, 256, FileName); //读取ini值,如果没找到默认是9600 GetPrivateProfileString("VelData", "Vel", "20000", vel, 256, FileName); //读取ini值,如果没找到默认是20000 comboBox_Ports.Text = com.ToString(); //初始化 comboBox_Bps.Text = bps.ToString(); numericUpDown_Vel.Value = decimal.Parse(vel.ToString()); serialPort1.DataReceived += SerialPort1_DataReceived; //添加串口接受数据事件 bufferChanged += new UpdateBufferEventHandle(HandleBuffer); //将事件处理方法添加到事件中去 InitFeedback(); //初始化回显 button_Close.Enabled = false; button_ControlSend.Enabled = false; button_ControlSend2.Enabled = false; button_Rec.Enabled = false; radioButton_Rec.Checked = true; //默认选中记录数据 }