Matthew
Matthew

Reputation: 640

How to automatically add text in listview in vb.net

Here is my code:

 If e.KeyCode = Keys.Enter Then
        lvFabric.Items.Item(0).Text = txtFind.Text
    End If

The code above is only specifying where the text should be added in the listview.

The flow of the whole function is first there is a textbox(txtFind),for example the user will input a text then press enter, after the user press enter the text will be added in the listview. the user will do this 3 times, what I want is how to automatically add text in listview without specifying the index.

Upvotes: 0

Views: 1719

Answers (1)

Obsidian Phoenix
Obsidian Phoenix

Reputation: 4155

Try this

If e.KeyCode = Keys.Enter Then
  lvFabric.Items.add(New ListViewItem(txtFind.Text))
End If

Upvotes: 2

Related Questions