hey, frnds I have two forms Forn1 & form2,On Form2 I have three Texyboxes & on form1 i have listview with three Columns.
I m sending the text from textboxes to listview.

I want that Multiple Rows should be added.
Suppose i write the value in three textboxes,with my code these are added in the listview.
But when i enter the second time values in textbox & send it to listvoiew,initial value of listview is replaced by these value.
I want both the values.
My code is as Under--

Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim obj As New Form1
obj.lvitem1 = obj.ListView1.Items.Add(Me.TextBox1.Text)
obj.lvitem1.SubItems.Add(Me.TextBox2.Text)
obj.lvitem1.SubItems.Add(Me.TextBox3.Text)

obj.Show()

Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
End Sub
End Class


Public Class Form1

Public lvitem1 As ListViewItem
End Class

Dim obj As New Form1
obj.lvitem1 = obj.ListView1.Items.Add(Me.TextBox1.Text)
obj.lvitem1.SubItems.Add(Me.TextBox2.Text)
obj.lvitem1.SubItems.Add(Me.TextBox3.Text)

If you just want each of the items to be added, you could just add each one to the listview as an item, ex.

ListView1.Items.Add(TextBox1.Text)
ListView1.Items.Add(TextBox2.Text)

or do you want the other boxes to be subitems?

Hi

Dim obj As New Form1

This creates everytime a new Form1 object so ListView must be clear.Each time you referring different object instance of Form1. If you want previous value then you have to have "obj" as Form member not a local object.

ex

Class Form2
  Dim obj as new Form1
  ..
  ..
  Button_Click Handler
   'You Coding
  

End Class

Note:
You should not close the form, otherwise it will lost all the values. It should be distroyed when Form2 is destroyed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.