Dim item = ListView2.Items.Add("...")
For cnt As Integer = 1 To ListView2.Columns.Count
item.SubItems.Add("")
Next
If ListView2.FocusedItem.ImageIndex = 10 Then
If TextBox2.Text.Length < 4 Then
TextBox2.Text = ""
End If
End If
The error I got is here:
If ListView2.FocusedItem.ImageIndex = 10 Then
Error name: object reference not set to an instance of an object
====================================================================
This is how it's really looks like:
Private Sub ListView2_DoubleClick(sender As Object, e As EventArgs) Handles ListView2.DoubleClick
If ListView2.FocusedItem.ImageIndex = 0 Or ListView2.FocusedItem.ImageIndex = 1 Or ListView2.FocusedItem.ImageIndex = 2 Then
If TextBox2.Text.Length = 0 Then
TextBox2.Text += ListView2.FocusedItem.Text
Else
TextBox2.Text += ListView2.FocusedItem.Text & "\"
End If
RefreshList()
End If
'from here doesn't work
If Not IsNothing(ListView2.FocusedItem) AndAlso ListView2.FocusedItem.ImageIndex = 10 Then
If TextBox2.Text.Length < 4 Then
TextBox2.Text = ""
Else
TextBox2.Text = TextBox2.Text.Substring(0, TextBox2.Text.LastIndexOf("\"))
TextBox2.Text = TextBox2.Text.Substring(0, TextBox2.Text.LastIndexOf("\") + 1)
RefreshList()
End If
End If
End Sub
Public Sub RefreshList()
ListView2.Items.Clear()
Dim item = ListView2.Items.Add("...")
For cnt As Integer = 1 To ListView2.Columns.Count
item.SubItems.Add("")
Next
End Sub