anyone know?
Printable View
anyone know?
Create a subroutine in a module like this:
Public Module Module1
Public Sub Add_Item(ByRef lvOne As ListView, ByVal sString As String)
lvOne.Items.Add(sString.Trim)
End Sub
End Module
In the first form, call this method:
Call Module1.Add_Item(objForm.lvTwo, "SomeString")
Basically you have the second form declared and instantiated and pass the ListView by reference along with a string you wish to populate inside.
I hope this helps.;)
how can you declare an instantiate it :)?
how can you declare an instantiate it ? :)
You can also use a delegate.
how? sorry im very new at vb.net :(
Forget what I said about using a delegate. This seems really simple. Where is the data coming from? If you want to add data to a listview, just open the form and add your data.
data is in form2, listview is in form1...
As I said before, place this in a module:
Public Module Module1
Public Sub Add_Item(ByRef lvOne As ListView, ByVal sString As String)
lvOne.Items.Add(sString.Trim)
End Sub
End Module
Now enter this code in Form2 (Maybe on a button click event or something:)
Call Module1.Add_Item(Form1.ListView1, "Somestring")
This should populate the listview on the first form.
Work with that.
in Form1 do this....
in Form2....VB Code:
[color=blue]Private Sub[/color] Button1_Click([color=blue]ByVal[/color] sender [color=blue]As[/color] System.Object, [color=blue]ByVal[/color] e [color=blue]As[/color] System.EventArgs) [color=blue]Handles[/color] Button1.Click [color=blue]Dim[/color] frm2 [color=blue]As New[/color] Form2() [color=blue]MyBase[/color].AddOwnedForm(frm2) '/// make form2 owned by form1. frm2.Show() [color=blue]End Sub[/color]
i've included a little demo to help it look easier...VB Code:
[color=blue]Private Sub[/color] Button1_Click([color=blue]ByVal[/color] sender [color=blue]As[/color] System.Object, [color=blue]ByVal[/color] e [color=blue]As[/color] System.EventArgs) [color=blue]Handles[/color] Button1.Click [color=blue]Dim[/color] frmMain [color=blue]As[/color] Form1 = [color=blue]MyBase[/color].Owner frmMain.ListView1.Items.Add("some stuff from form2!") [color=blue]End Sub[/color]
ty :)