would you all help me?

how do i do, when i double click at item using list view then bring and display the items at textbox and option button at the another form??please help me...im in urgent...thank you so much..

would you all help me?

how do i do, when i double click at item using list view then bring and display the items at textbox and option button at the another form??please help me...im in urgent...thank you so much..

When you double-click on the listview box, you are actually clicking on index numbered item in that listbox. If you use the Index.text and the Forms.frmName.frmFieldName.Text, you should be able to copy any index from the listbox to the other form's textbox or field.

make a public shared variable to accomodate your item and you can call it in other form.

When you double-click on the listview box, you are actually clicking on index numbered item in that listbox. If you use the Index.text and the Forms.frmName.frmFieldName.Text, you should be able to copy any index from the listbox to the other form's textbox or field.

Hi....SolTec

Thanks yeah for your reply
but if u dont mind...can u guide me with some sample code
actually i dont know about vb.net much...

Thanks

make a public shared variable to accomodate your item and you can call it in other form.

Hi....Jx_Man

Thanks yeah for your reply
but if u dont mind...can u guide me with some sample code
actually i dont know about vb.net much...

Thanks

Hi....SolTec

Thanks yeah for your reply
but if u dont mind...can u guide me with some sample code
actually i dont know about vb.net much...

Thanks

Create a project with Form1 and Form2, place a button on Form1 along with a listbox and label

In Form1 load event place this:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lstListBox.Items.Add("Item1")
lstListBox.Items.Add("Item2")
lstListBox.Items.Add("Item3")

End Sub

To add the item from Form1 to Form2, ass this code in the listbox double-click event

Private Sub lstListBox_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstListBox.MouseDoubleClick
If lstListBox.SelectedIndex = -1 Then
MsgBox("Please select an item in the list and double-left click it with your mouse")
Else
Form2.frm2Label.Text = lstListBox.Text
Form2.frm2ListBox.Text = Form2.frm2ListBox.Items.Add(lstListBox.Text)
End If

End Sub

And, finally to see your selected item added to your listbox and label on Form2, press the button.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As Form
frm = Form2
frm.Show()
End Sub

Hi....Jx_Man

Thanks yeah for your reply
but if u dont mind...can u guide me with some sample code
actually i dont know about vb.net much...

Thanks

this code in form 1

Public Shared temp As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 1 To 10
ListView1.Items.Add(i)
Next i
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim frm2 As New Form2
    frm2.Show()
End Sub

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
    temp = ListView1.SelectedItems(0).Text
    Label1.Text = ListView1.SelectedItems(0).Text
End Sub

this code in form 2 :

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = Form1.temp
End Sub

This an attachment of my code
ListView - Daniweb.zip

Ok. Hope this helps..

commented: Mentari +1
commented: great :) +1

hi...

thanxx yeah soltex...
thank you so much..
for helping me...

i really appreciate thats...

thanks again...

hi...

thanxx yeah Jx_Man.
thank you so much..
for helping me...

i really appreciate thats...

thanks again...

why every time, when i running the project then this error will come out InvalidArgument=Value of '1' is not valid for 'index'.
Parameter name: index

if i put SelectedItems(0).Text can run..
but if i put SelectedItems(1).Text then cannot run..

why?

your just have 1 column and index is 0.
selectedItems(0) -> selected item on column 0
selectedItems(1) -> selected item on column 1

but why its cannot run..
i know about..

selectedItems(0) -> selected item on column 0
selectedItems(1) -> selected item on column 1

but its still cannot run...

hello u guys..

thank you coz helping me...

now i'm done..
thanks a lot..

oh, you was done. great.
don't forget to mark this solved.
happy coding friend :)

why every time, when i running the project then this error will come out InvalidArgument=Value of '1' is not valid for 'index'.
Parameter name: index

if i put SelectedItems(0).Text can run..
but if i put SelectedItems(1).Text then cannot run..

why?

When VB builds a control, it uses an index of -1 as No Index or NULL and 0 as index one, that's why, when you want the index chosen value it is IndexValue.Item -1 that gives you the proper index value chosen.

So, if you have 8 items they will be 0-7 instead of 1-8.

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.