Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //初始化控件
            foreach (string s in SerialPort.GetPortNames())
            {
                comboBox1.Items.Add(s);
            }
            if (comboBox1.Items.Count == 0)
            {
                label3.Text      = "未检测到串口";
                label3.ForeColor = Color.Red;
            }
            else
            {
                comboBox1.SelectedIndex = 0;
            }
            comboBox2.SelectedIndex = 0;

            //初始化设备类对象 gm
            if (comboBox1.Items.Count == 0)
            {
            }
            else
            {
                gm.ComPort = comboBox1.SelectedItem.ToString();
            }
            gm.BaudRate = Convert.ToInt32(comboBox2.SelectedItem);

            gm.SmsRecieved += new EventHandler(gm_SmsRecieved);

            UpdateHandle = new UpdataDelegate(UpdateLabel8);        //实例化委托
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //初始化控件
            foreach (string s in SerialPort.GetPortNames())
            {
                comboBox1.Items.Add(s);
            }
            if (comboBox1.Items.Count == 0)
            {
                label3.Text = "未检测到串口";
                label3.ForeColor = Color.Red;
            }
            else
            {
                comboBox1.SelectedIndex = 0;
            }
            comboBox2.SelectedIndex = 0;

            //初始化设备类对象 gm
            if (comboBox1.Items.Count == 0)
            {

            }
            else
            {
                gm.ComPort = comboBox1.SelectedItem.ToString();
            }
            gm.BaudRate = Convert.ToInt32(comboBox2.SelectedItem);

            gm.SmsRecieved +=new EventHandler(gm_SmsRecieved);

            UpdateHandle = new UpdataDelegate(UpdateLabel8);        //实例化委托
        }