未声明ListView1可能是由于其保护级别

时间:2016-09-01 14:33:03

标签: vb.net variables methods visual-studio-2015

Interface screenshot

Dim rtb As New RichTextBox
    rtb.AppendText("Generation, Num Of Juveniles, Num of Adults, Num of Semiles, Total" & vbNewLine)
    For Each saveitem As ListViewItem In ListView1.Items
        rtb.AppendText(
                         saveitem.Text & ", " &
                        saveitem.SubItems(1).Text & ", " &
                       saveitem.SubItems(2).Text & ", " &
                      saveitem.SubItems(3).Text & ", " &
                     saveitem.SubItems(4).Text & vbNewLine)
    Next
    rtb.SaveFile("C:\Users\SMITH\Documents\Visual Studio 2013\Projects\Test.txt",
      RichTextBoxStreamType.PlainText)
End Sub

Private Sub Results_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Call Init(ListView1.Items)

End Sub

我一直得到错误listview1未声明它可能是由于它的保护级别。我是VB的新手,并且已经在这方面工作了一段时间。有没有人有这个编码解决方案或可能指向我的写方向。非常感谢

1 个答案:

答案 0 :(得分:0)

您可以从另一个表单访问ListView1作为Form1.ListView1