尝试将C#转换为VB,但我不断收到以下错误:
属性子项是ReadOnly
和
String()的值无法转换为ListViewItem.ListViewSubItemCollection
我的代码如下:
ListView1.Items.Clear()
For int_0 As Integer = 0 To 17
Dim tuple As Tuple(Of String, String, String) = pullMem(int_0)
If tuple.Item3.Contains("09") Then
Me.ListView1.Items.Add(New ListViewItem(tuple.Item1) With {
.SubItems = {tuple.Item2, tuple.Item3}
})
End If
Next int_0
Catch e1 As Exception
MessageBox.Show("You must connect first!", "Error")
End Try
答案 0 :(得分:1)
是的,你可以在VB.Net中实例化那些子项。尝试只创建ListView项,然后将子项添加到它:
Dim lvi As New ListViewItem(tuple.Item1)
lvi.SubItems.AddRange({tuple.Item2, tuple.Item3}.ToArray())
ListView1.Items.Add(lvi)