Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am maked a common listview selection form for data seletion
expample
when its opend from accname textbox then show accounts list
on selection fill accname textbox
when its opend from item textbox then show itemlist
on selection fill itemname textbox
any many more taxboxes like taxtype,broker,godown etc


what my problem is how to send data form it to
its calling textbox
if opend from accname textbox then if dataselected fill it to accname text box
Posted

1 solution

First, I'm using VB 2005 so a bit rusty with the differences. But if I'm understanding you correctly you want 2 or more forms up and be able to make changes to your main form using the other(s). Correct?

I'll show you for 2 forms. We'll just call your main form "Form1" and a 2nd form as "Form2".

Now, if you have 3 columns in your listview on Form1 and want each column of the selected line to show up on Form2 you would do something like this:

VB
Private Sub lvwTaxList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwTaxList.DoubleClick
    'Brings up your 2nd Form
    Form2.Show()

    'Sends the data from each column in Selected row to appropriate text boxes on 2nd Form
    '   "lvwTaxList" would be your Listview
    '     "Item(lvwTaxList.FocusedItem.Index)" is the Selected row
    '       "SubItems(#)" are the columns {zero-based}
    Form2.txtTaxType.text = lvwTaxList.Item(lvwTaxList.FocusedItem.Index).SubItems(0).Text
    Form2.txtBroker.text = lvwTaxList.Item(lvwTaxList.FocusedItem.Index).SubItems(1).Text
    Form2.txtGoDown.text = lvwTaxList.Item(lvwTaxList.FocusedItem.Index).SubItems(2).Text
End Sub


Just put your own Form & Control names in the right places and the above code should work for you. If you want changes from your 2nd Form to be sent back to your 1st Form you would use the reverse method in the coding for your 2nd Form:

VB
Form1.lvwTaxList.Item(lvwTaxList.FocusedItem.Index).SubItems(0).Text = txtTaxType.text


Hope this helps!

Peace to you and yours,
Matthew "Dra'Gon" Stohler
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900