SerialPortCombox.cs 947 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 FileWatcher
  11. {
  12. public partial class SerialPortCombox : UserControl
  13. {
  14. public SerialPortCombox()
  15. {
  16. InitializeComponent();
  17. }
  18. public override string Text
  19. {
  20. get
  21. {
  22. return ComCombox.Text;
  23. }
  24. set
  25. {
  26. ComCombox.Text = value;
  27. }
  28. }
  29. private void SerialPortCombox_Load(object sender, EventArgs e)
  30. {
  31. string[] str= SerialPort.GetPortNames();
  32. for (int i = 0; i < str.Length; i++)
  33. {
  34. Console.WriteLine(str[i]);
  35. }
  36. ComCombox.Items.AddRange(SerialPort.GetPortNames());
  37. }
  38. }
  39. }