简体   繁体   English

如何在文本框中保存用户输入的值?

[英]How to save user inputted value in TextBox?

I have a Textbox that I want to be saved after it is closed, and then given to another computer. 我有一个文本框,它要在关闭后保存,然后提供给另一台计算机。

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  

In Settings I have a Setting called TextBoxValues 在设置中,我有一个名为TextBoxValues的设置
system.collections.specialized.stringcollection system.collections.specialized.stringcollection
And then, this works with Scope User, but it doesn't save if the application is moved, or given to another computer. 然后,它适用于Scope User,但如果应用程序被移动或分配给另一台计算机,则不会保存。 So I have to change the Scope to Application. 所以我必须将范围更改为“应用”。 But when I turn it to Application I get this Error: 但是,当我将其转到应用程序时,出现此错误:
Property 'TextBoxValues' is 'ReadOnly'. 属性“ TextBoxValues”为“ ReadOnly”。 for 对于

.TextBoxValues = New System.Collections.Specialized.StringCollection

I think you must save in a txt file, XML or somethig .. 我认为您必须保存为txt文件,XML或somethig ..
because in other way how you keep dtat typed data ? 因为以其他方式如何保留dtat类型的数据? :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM