12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Windows.Forms;
- using System.IO.Ports;
- namespace UAS_LabelMachine.CustomControl
- {
- public partial class SerialPortCombox : UserControl
- {
- public SerialPortCombox()
- {
- InitializeComponent();
- }
- public override string Text
- {
- get
- {
- return ComCombox.Text;
- }
- set
- {
- ComCombox.Text = value;
- }
- }
- public string SelectedText
- {
- get
- {
- return ComCombox.SelectedText;
- }
- set
- {
- ComCombox.SelectedText = value;
- }
- }
- public object SelectedValue
- {
- get
- {
- return ComCombox.SelectedValue;
- }
- set
- {
- ComCombox.SelectedValue = value;
- }
- }
- public object Items
- {
- get
- {
- return ComCombox.Items;
- }
- }
- private void SerialPortCombox_Load(object sender, EventArgs e)
- {
- ComCombox.Items.AddRange(SerialPort.GetPortNames());
- foreach (var item in ComCombox.Items)
- {
- if (item.ToString() == Properties.Settings.Default.PortName)
- {
- ComCombox .SelectedIndex= ComCombox.Items.IndexOf(item);
- return;
- }
- }
- }
- }
- }
|