我将MySettings
(Usr1,Usr2,Usr3,Usr4)中的4个对象设置为System.Collections.Specialized.StringCollection
。
我以这种方式给它赋值(并且它有效):
For x As Integer = 1 To 4
If My.Settings.Item("Usr" & x.ToString) Is Nothing Then
My.Settings.Item("Usr" & x.ToString) = New System.Collections.Specialized.StringCollection _
From {Me.TBox_Name.Text, _
Me.Tbox_Surname.Text, _
Me.TBox_City.Text, _
Me.CBox_Age.Text}
My.Settings.Save()
Saved = True
Exit For
End If
Next
当我尝试删除记录并将对象设置为空时我无法匹配
这是我尝试过的:
Dim ToDelete = New System.Collections.Specialized.StringCollection _
From {Me.TBox_Name.Text, _
Me.Tbox_Surname.Text, _
Me.TBox_City.Text, _
Me.CBox_Age.Text}
If Not My.Settings.Usr1 Is Nothing AndAlso My.Settings.Usr1.Equals(ToDelete) Then
My.Settings.Usr1 = Nothing
End If
If Not My.Settings.Usr2 Is Nothing AndAlso My.Settings.Usr2.Equals(ToDelete) Then
My.Settings.Usr2 = Nothing
End If
If Not My.Settings.Usr3 Is Nothing AndAlso My.Settings.Usr3.Equals(ToDelete) Then
My.Settings.Usr3 = Nothing
End If
If Not My.Settings.Usr4 Is Nothing AndAlso My.Settings.Usr4.Equals(ToDelete) Then
My.Settings.Usr4 = Nothing
End If
但我从来没有找到平等的:没有比赛。
我尝试从设置中获取值并将它们放入文本框中。所以我确信文本框中的值等于我的设置,但我的代码无法识别它
我哪里错了?
还有其他办法吗?
答案 0 :(得分:0)
这是一个简单的命令。
My.Settings.Usr1.Clear()