Results 1 to 5 of 5

Thread: Writing Selected ListBox Item to DB...[RESOLVED - x2]

  1. #1

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Resolved Writing Selected ListBox Item to DB...[RESOLVED - x2]

    Ok, here's an easier one (for you, not me). I'm trying to write a selected item in a listbox to my db, and I get various results with different choices.

    I've tried:

    listbox.SelectedItem
    listbox.SelectedValue
    listbox.SelectedIndex
    listbox.DataSource
    listbox.DisplayMember

    I've tried them all with .ToString added, also.

    I get db entries ranging from

    "

    to

    System.Data.DataRowView

    but no actual entry that looks anything like the customername and partnumber that's selected in the ListBox.
    Last edited by milkmood; Jun 15th, 2005 at 01:56 PM.
    When I say 'jump', don't waste time asking 'how high?'.

    Just a poor, dumb wanna-be programmer.

  2. #2
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: Writing Selected ListBox Item to DB...

    ListBox1.SelectedItems.Item(0))

  3. #3

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Re: Writing Selected ListBox Item to DB...

    I found it, thanks Matt! The answer is here:

    http://www.vbforums.com/showpost.php...4&postcount=11

    VB Code:
    1. listbox.GetItemText(listbox.SelectedItem)
    When I say 'jump', don't waste time asking 'how high?'.

    Just a poor, dumb wanna-be programmer.

  4. #4

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Re: Writing Selected ListBox Item to DB...

    Hey Andy, that works, too (minus the second ")")...thanks. SO, which method is more reliable? Does it matter?

    And thanks for changing your av...your arm must be really sore by now.
    When I say 'jump', don't waste time asking 'how high?'.

    Just a poor, dumb wanna-be programmer.

  5. #5
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: Writing Selected ListBox Item to DB...

    Quote Originally Posted by milkmood
    And thanks for changing your av...your arm must be really sore by now.
    hee hee...you're welcome

    as far as 'reliability', i always use that code. i've never had a prob...one thing you might wanna add is a Trim() around the text to ensure you don't waste any space on your db.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width