Solved

Listbox

Posted on 2006-06-12
3
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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