[英]How to save user inputted value in 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或somethig ..
因為以其他方式如何保留dtat類型的數據? :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.