Solved

Listbox

Posted on 2006-06-12
3
283 Views
Last Modified: 2010-04-23
I have form1 which has a button which allows a user to lookup a customer name.  The button, when clicked opens another form (form2) which contains a listbox and the customer names are listed in the listbox bounded from a datasource (sql table).  I would like the user to be able to select an item in the listbox (by highlighting it) and clicking the select button at the bottom of the form2 and then have the item display in a text box on form1.  I am trying the following code to accomplish this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click

        form1.tbItemNmbr.Text = Me.lbItems.SelectedItem.ToString
       
    End Sub

The code displays "System.Data.DataRowView" in the text box not the customer name as desired.  Can someone point me in the right direction on this?
0
Comment
Question by:mwalsh2000
  • 2
3 Comments
 
LVL 10

Expert Comment

by:vadim63
ID: 16889100
You have to set    Me.ListBox1.ValueMember = "Customer Name" and then use:

form1.tbItemNmbr.Text = Me.lbItems.SelectedValue
0
 
LVL 10

Accepted Solution

by:
vadim63 earned 500 total points
ID: 16889106
I mean:  Me.lbItems.ValueMember = "Customer Name"
0
 

Author Comment

by:mwalsh2000
ID: 16889164
That got it, thanks!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question