Click here to Skip to main content
13,139,569 members (50,191 online)
Rate this:
Please Sign up or sign in to vote.
See more:
My project has the Main Form with a listbox and a menu item that calls up another form with a listbox. I wanted to be able to select an item in the second listbox and by double clicking add it to the listbox on the main form.

I can't get this to work and I wondered if it was a "Modal" thing?
Posted 18-Jul-10 18:25pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try This

Private Sub Listbox1_DoubleClick(Byval sender as Object, Byval e as system.eventargs) Handles Listbox1.DoubleClick
'Check for selected item
If Not listbox1.SelectedItem = Nothing Then
'add it
'if user did not select item, notify them
MsgBox("Please double click an item from the list.", MsgBoxStyle.OkOnly,"Please Select An Item")
End If
End Sub

listbox1 = the list box on the second form
listbox2 = the list box on your main form
form1 = the second form

Good Luck in your programming :-)
Sandeep Mewara 19-Jul-10 2:32am
Comment from OP: Thanks for that, and your good wishes.

But when I try that I get a message from VB something like:
"listbox2 is not a member of form1"

My original code based on the Parameters you mention is:

and that's the code that's not working.
Paul Bayley 19-Jul-10 3:53am
My sincere apologies. I failed to cover all the possibilities as to why my code wasn't working (I never learn !!).
The problem actually originated in that the listbox on the main form was one of a number, one on each tab page of a tab control. The "active tab" string returned I presumed to be "0" for page one, "1" for page two etc. this I have now found to be "" for page 1, "1" for page 2 etc.

The Select Case "active tab string"
Case "0"
drew a blank !!!

Now Case "" works fine............once again my apologies for wasting your time.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 19 Jul 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100