|
-
Jun 15th, 2005, 01:33 PM
#1
Thread Starter
Lively Member
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.
-
Jun 15th, 2005, 01:43 PM
#2
Frenzied Member
Re: Writing Selected ListBox Item to DB...
ListBox1.SelectedItems.Item(0))
-
Jun 15th, 2005, 01:46 PM
#3
Thread Starter
Lively Member
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:
listbox.GetItemText(listbox.SelectedItem)
When I say 'jump', don't waste time asking 'how high?'.

Just a poor, dumb wanna-be programmer.
-
Jun 15th, 2005, 01:53 PM
#4
Thread Starter
Lively Member
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.
-
Jun 15th, 2005, 02:01 PM
#5
Frenzied Member
Re: Writing Selected ListBox Item to DB...
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|