Zeltron playz Zeltron playz - 5 months ago 17
Vb.net Question

Adding stuff to listview from textbox

id like to know how to take one of my text boxs or strings and put it in a listview.. well not really let me show u wants going on.

i have a 2 text box with the following stuff

TextBox1

cat123
hatcat
quanwall
samiam12


TextBox2

John
will
sam
dan


i want to take TextBox1's text and put it in one of the columns in the ListView. for example. ListView has 2 columns saying usernames and realnames, and TextBox1 is the usernames and TextBox2 is the realnames. So i want to take each line in TextBox1 to match up with the RealNames(TextBox2) all in ListView.

iv bin using the

Dim Q As New ListViewItem
Q.Text = Host
Q.SubItems.Add(User)
Q.SubItems.Add(Pass)
ListView1.Items.Add(Q)


to add the strings to the listview

I need this information ASAP, Thx u <3

Answer

Try this (To listview1 put your listview name)

Dim i As Integer = 0
    For Each l In TextBox1.Lines
        ListView1.Items.Add(l)
        ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TextBox2.Lines(i))
        i += 1
    Next
    i = 0