By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

On form1 I instantiate form2 with a list box. I do I handle listboxclick from form1

P: n/a
Form2 has one purpose to open and list some names and ids. I want to
handle the list box click event on form2 so I can get the selected
value onto a field in form1.

I changed this
Dim MyForm2 As New PHfx.Form2
to
With Events MyForm2 As New PHfx.Form2
and tried adding an event handler but intellisense will not show form2s
objects, just the methods.

This does not pull up the intellisense
sub onlistClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) handles MyForm2.XXXXXX - where is my listbox listed so
I can handle it's click event and get the selectedvalue.

Thanks,
Phil
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You can pass a reference of form1 into form two at creation. Then just fill
in the property you need.

Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub
Sub SomethingDone()
RefToForm1.FieldToUpdate = Data
End Sub
end class

Hope it helps
Chris

"PAPutzback" <Ph**************@insightbb.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Form2 has one purpose to open and list some names and ids. I want to
handle the list box click event on form2 so I can get the selected value
onto a field in form1.

I changed this
Dim MyForm2 As New PHfx.Form2
to
With Events MyForm2 As New PHfx.Form2
and tried adding an event handler but intellisense will not show form2s
objects, just the methods.

This does not pull up the intellisense
sub onlistClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) handles MyForm2.XXXXXX - where is my listbox listed so I
can handle it's click event and get the selectedvalue.

Thanks,
Phil

Nov 21 '05 #2

P: n/a
It isn't clear to me. When an item is selected in the listbox on form 2
I want to see the selected value from form1 and put it into a text
box.with no user intervention other than clicking the listbox on form
2.

I thought I could add a handler to form1 to handle the click event of
the listbox on form2

Or maybe I just get the syntax of the code you put up

Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Thanks,
Phil

Nov 21 '05 #3

P: n/a
Sorry I think I misunderstood what you wanted.

You want the user to select an item in Form2.listbox. Then get a value from
Form1.SomeControl and put it into a Form2.Textbox. The idea behind my code
will still work. You may be able do what your talking about doing, I've
just never done it.

So in this example Form2 now has a reference to Form1 called "RefToForm1"
Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Sub OnClickListBox(....) handles Listbox1......
Textbox1.Text = RefToForm1.GetSomeValueFromForm1(SomeThingPassedIn )
End Sub
End Sub

Class Form1
Sub OpenForm2
Dim F2 as New Form2(Me)
F2.ShowDialog()
End Sub

Public Function GetSomeValueFromForm1(ByVal SomeValueFromForm2 as
String) as String
return WhateverYouWantedOnForm2
end function
End Class

Obviously I wrote the code in here ad it wasn't tested. But that is the
idea. Form2 now has knowledge about Form1. Form1 now has a method that
Form2 can call and return some value to Form2.

I hope this helps
Chris

"PAPutzback" <ph**************@insightbb.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
It isn't clear to me. When an item is selected in the listbox on form 2
I want to see the selected value from form1 and put it into a text
box.with no user intervention other than clicking the listbox on form
2.

I thought I could add a handler to form1 to handle the click event of
the listbox on form2

Or maybe I just get the syntax of the code you put up

Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Thanks,
Phil

Nov 21 '05 #4

P: n/a
I got thru this by binding the text box to the selected value of the list
box.

Me.txt_Provider.DataBindings.Add( _
New Binding("text", My_PCPlist.PCPList, "SelectedValue"))

Thanks,
Phillip

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uj**************@TK2MSFTNGP11.phx.gbl...
Sorry I think I misunderstood what you wanted.

You want the user to select an item in Form2.listbox. Then get a value
from Form1.SomeControl and put it into a Form2.Textbox. The idea behind
my code will still work. You may be able do what your talking about
doing, I've just never done it.

So in this example Form2 now has a reference to Form1 called "RefToForm1"
Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Sub OnClickListBox(....) handles Listbox1......
Textbox1.Text = RefToForm1.GetSomeValueFromForm1(SomeThingPassedIn )
End Sub
End Sub

Class Form1
Sub OpenForm2
Dim F2 as New Form2(Me)
F2.ShowDialog()
End Sub

Public Function GetSomeValueFromForm1(ByVal SomeValueFromForm2 as
String) as String
return WhateverYouWantedOnForm2
end function
End Class

Obviously I wrote the code in here ad it wasn't tested. But that is the
idea. Form2 now has knowledge about Form1. Form1 now has a method that
Form2 can call and return some value to Form2.

I hope this helps
Chris

"PAPutzback" <ph**************@insightbb.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
It isn't clear to me. When an item is selected in the listbox on form 2
I want to see the selected value from form1 and put it into a text
box.with no user intervention other than clicking the listbox on form
2.

I thought I could add a handler to form1 to handle the click event of
the listbox on form2

Or maybe I just get the syntax of the code you put up

Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Thanks,
Phil


Nov 21 '05 #5

P: n/a
Hi

I think it is easier with ShowDialog method (if the form2 only purpouse is
to select a provider) then could do something like this:

class form1
sub getProvider
provider as string
provider=form2.showDialog
end sub
end class

class form2
sub HandlesClick (sender...) Handles list.click
Me.tag=list.selectedvalue
me.close
end sub
end class

This code is pseudoCode Too but surely works

Regards!

Omar Rojas

"PAPutzback" wrote:
I got thru this by binding the text box to the selected value of the list
box.

Me.txt_Provider.DataBindings.Add( _
New Binding("text", My_PCPlist.PCPList, "SelectedValue"))

Thanks,
Phillip

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:uj**************@TK2MSFTNGP11.phx.gbl...
Sorry I think I misunderstood what you wanted.

You want the user to select an item in Form2.listbox. Then get a value
from Form1.SomeControl and put it into a Form2.Textbox. The idea behind
my code will still work. You may be able do what your talking about
doing, I've just never done it.

So in this example Form2 now has a reference to Form1 called "RefToForm1"
Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Sub OnClickListBox(....) handles Listbox1......
Textbox1.Text = RefToForm1.GetSomeValueFromForm1(SomeThingPassedIn )
End Sub
End Sub

Class Form1
Sub OpenForm2
Dim F2 as New Form2(Me)
F2.ShowDialog()
End Sub

Public Function GetSomeValueFromForm1(ByVal SomeValueFromForm2 as
String) as String
return WhateverYouWantedOnForm2
end function
End Class

Obviously I wrote the code in here ad it wasn't tested. But that is the
idea. Form2 now has knowledge about Form1. Form1 now has a method that
Form2 can call and return some value to Form2.

I hope this helps
Chris

"PAPutzback" <ph**************@insightbb.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
It isn't clear to me. When an item is selected in the listbox on form 2
I want to see the selected value from form1 and put it into a text
box.with no user intervention other than clicking the listbox on form
2.

I thought I could add a handler to form1 to handle the click event of
the listbox on form2

Or maybe I just get the syntax of the code you put up

Class Form2
RefToForm1 as Form1
sub new (ByRef F as Form1)
mybase.new()
RefToForm1 = F
end sub

Thanks,
Phil



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.