在组合框索引中保存comport数 [英] Saving comport number in combobox index

查看:99
本文介绍了在组合框索引中保存comport数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦用户从组合框中选择了他的CommPort编号,它是否可能被保存,当程序将重新运行时 - 组合框中的值将被保存,所以

Is it possbile to once user selected hes CommPort Number from combobox , it will be saved and when programm will be reruned - value in combobox will be saved, so

.PortName = cboComPort.Text 

无需预先选择即可工作



我尝试过:



will work without pre-selecton

What I have tried:

Dim Portnames As String() = SerialPort.GetPortNames
If Portnames.Length = 0 Then
    MsgBox("Сперва подключите устройство")

    Me.Close()
    Exit Sub
End If
cboComPort.Items.AddRange(Portnames)
cboComPort.Text = Portnames(0)

推荐答案

要存储简单值,通常使用注册表。在Microsoft的这篇文章中,关于 Registry.GetValue 你找到了解释和一些示例代码。您必须在程序启动或退出时加载并保存这些设置。
To store simple value you normally use the registry. In this article from Microsoft about Registry.GetValue youfind explanation and some sample code. You must load and save these settings at startup or exit of your program.


这篇关于在组合框索引中保存comport数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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