我创建了这个列表视图框,当双击内容时,值会插入到文本框中。一些项目中有空格,一些子项目中有空值。单击这些特定列表项时,软件会崩溃。有没有办法可以检查子项是空的还是空的?
Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
For i As Integer = 1 To 7
Dim tbName As String = "TextBox" & i
Dim matches() As Control = Me.Controls.Find(tbName, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is TextBox Then
Dim tb As TextBox = DirectCast(matches(0), TextBox)
If tb.Text.Trim.Length = 0 Then
tb.Text = ListView1.SelectedItems(0).SubItems(0).Text
Exit Sub
End If
End If
Next