如何在 TextBox 中保存用户输入的值?
How to save user inputted value in TextBox?
我有一个Textbox,我想在关闭后保存,然后再给另一台电脑。
Public Class Form1
Dim textBoxes() As TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
textBoxes = New TextBox() {TextBox2}
With My.Settings
If .TextBoxValues Is Nothing Then .TextBoxValues = New System.Collections.Specialized.StringCollection
For i = 0 To textBoxes.Length - 1
If .TextBoxValues.Count <= i Then .TextBoxValues.Add("")
textBoxes(i).Text = .TextBoxValues(i)
Next
End With
在设置中我有一个名为 TextBoxValues 的设置
system.collections.specialized.stringcollection
然后,这适用于 Scope User,但如果应用程序被移动或提供给另一台计算机,它不会保存。所以我必须将范围更改为应用程序。但是当我把它转到应用程序时,我得到了这个错误:
属性 'TextBoxValues' 是 'ReadOnly'。
对于
.TextBoxValues = New System.Collections.Specialized.StringCollection
我认为您必须保存在 txt 文件中,XML 或其他文件 ..
因为在其他情况下您如何保存 dtat 类型的数据? :)
我有一个Textbox,我想在关闭后保存,然后再给另一台电脑。
Public Class Form1
Dim textBoxes() As TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
textBoxes = New TextBox() {TextBox2}
With My.Settings
If .TextBoxValues Is Nothing Then .TextBoxValues = New System.Collections.Specialized.StringCollection
For i = 0 To textBoxes.Length - 1
If .TextBoxValues.Count <= i Then .TextBoxValues.Add("")
textBoxes(i).Text = .TextBoxValues(i)
Next
End With
在设置中我有一个名为 TextBoxValues 的设置
system.collections.specialized.stringcollection
然后,这适用于 Scope User,但如果应用程序被移动或提供给另一台计算机,它不会保存。所以我必须将范围更改为应用程序。但是当我把它转到应用程序时,我得到了这个错误:
属性 'TextBoxValues' 是 'ReadOnly'。
对于
.TextBoxValues = New System.Collections.Specialized.StringCollection
我认为您必须保存在 txt 文件中,XML 或其他文件 ..
因为在其他情况下您如何保存 dtat 类型的数据? :)