如何将可用的串行端口添加到Combobox? [英] How Can I Add Available Serial Ports To Combobox?

查看:137
本文介绍了如何将可用的串行端口添加到Combobox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问如何将可用端口添加到我的组合框???

Hi,Please how can i add available ports to my combobox???

推荐答案

询问如何添加可用端口到是没有意义的combobox ..而应该是如何找到可用的端口......。如果你真的要用ports做一些东西,那么我相信你会知道如何绑定一个组合框或如何将一个项目添加到一个组合框中。



获取所有串口

It doen't make sense to ask "How to add available ports to combobox.." rather it should be "how to find available ports..". If you are really going to make something with the ports then I am sure you would be knowing how to bind a combobox or how to add an item to a combobox.

Get all serial ports
string[] ports = SerialPort.GetPortNames();



参考: SerialPort.GetPortNames Method() [ ^ ]



如果你仍然想知道如何将这个结果添加到你的组合框中,你可以尝试类似的事情 -


Reference: SerialPort.GetPortNames Method ()[^]

If you still want to know, how this result can be added to your combobox, you can try something like-

myComboBox.DataSource = ports;
myComboBox.DataBind();





希望,它有帮助:)



Hope, it helps :)


SerialPort.GetPortNames应该完成这项工作。有关详细信息,请查看 https: //msdn.microsoft.com/de-de/library/system.io.ports.serialport.getportnames(v=vs.110).aspx [ ^ ]

我希望它有所帮助。
SerialPort.GetPortNames should do the Job. For details please have a look to https://msdn.microsoft.com/de-de/library/system.io.ports.serialport.getportnames(v=vs.110).aspx[^]
I hope it helps.


这篇关于如何将可用的串行端口添加到Combobox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆