Aug 4th, 2003, 09:42 PM
#1
Thread Starter
Frenzied Member
How can you add data to a listview located on another form?
Aug 5th, 2003, 02:03 PM
#2
Hyperactive Member
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.
Aug 5th, 2003, 05:27 PM
#3
Thread Starter
Frenzied Member
how can you declare an instantiate it ?
Aug 5th, 2003, 07:57 PM
#4
Thread Starter
Frenzied Member
how can you declare an instantiate it ?
Aug 5th, 2003, 08:13 PM
#5
Frenzied Member
You can also use a delegate.
Aug 5th, 2003, 10:12 PM
#6
Thread Starter
Frenzied Member
how? sorry im very new at vb.net
Aug 5th, 2003, 10:34 PM
#7
Frenzied Member
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.
Aug 5th, 2003, 10:55 PM
#8
Thread Starter
Frenzied Member
data is in form2, listview is in form1...
Aug 6th, 2003, 07:42 AM
#9
Hyperactive Member
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.
Aug 6th, 2003, 08:04 AM
#10
in Form1 do this....
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]
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] frmMain [color=blue]As[/color] Form1 = [color=blue]MyBase[/color].Owner
frmMain.ListView1.Items.Add("some stuff from form2!")
[color=blue]End Sub[/color]
i've included a little demo to help it look easier...
Attached Files
~
if a post is resolved, please mark it as [Resolved ]
protected string get_Signature(){return Censored;}
[vbcode ][php ] please use code tags when posting any code [/php ][/vbcode ]
Aug 6th, 2003, 01:42 PM
#11
Thread Starter
Frenzied Member
ty
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width