Pass SelectedIndex to other Form

Fritz

Freshman
Joined
Oct 6, 2002
Messages
40
Location
switzerland
How can I do this? I'm trying like this:

Dim frm2 As New frm2()

frm2.BindingContext(objDataSet1, "MyTable").EndCurrentEdit()
frm2.BindingContext(objDataSet1, "MyTable").Position = Me.ListBox1.SelectedIndex

I've tried other things also, but I mean it must be somewhere around this.

I select a user from ListBox1. But when I open frm2, the index ist still at the first position.

I think it must be possible. Can anybody help me, please?
 
Place a Property Get/Set in frm2, Set its' value before you open frm2 then in the New or Load of frm2 Get the Index from the Property.
 
Thanks for the ideas. I have found another possibility now.

First I create a module:

Module SharedFormInstances
Public myForm1 As New Form1()
Public myForm2 As New Form2()
End Module

That gives me access from each form to each other form, without having to declare a lot of things.

Now in the sub form_load I have to declare only "myForm(x)=Me. And then the code goes:

Private Sub Form2_load (...)
myForm1=Me
Me.LoadDataSet()
Me.BindingContext(objDataSet1, "MyTable").EndCurrentEdit()
Me.BindingContext(objDataSet1, "MyTable").Position = myForm2.ListBox1.SelectedIndex
End Sub

Hope that helps anybody else also.
 
Back
Top