SerialPortCombox.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO.Ports;
  10. namespace UAS_MES_NEW.CustomControl.ComBoxWithFocus
  11. {
  12. public partial class SerialPortCombox : UserControl
  13. {
  14. public SerialPortCombox()
  15. {
  16. InitializeComponent();
  17. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  18. }
  19. public override string Text
  20. {
  21. get
  22. {
  23. return ComCombox.Text;
  24. }
  25. set
  26. {
  27. ComCombox.Text = value;
  28. }
  29. }
  30. private void SerialPortCombox_Load(object sender, EventArgs e)
  31. {
  32. string[] str= SerialPort.GetPortNames();
  33. for (int i = 0; i < str.Length; i++)
  34. {
  35. Console.WriteLine(str[i]);
  36. }
  37. ComCombox.Items.AddRange(SerialPort.GetPortNames());
  38. }
  39. }
  40. }