|
-
Feb 6th, 2002, 12:17 PM
#1
Thread Starter
Lively Member
get text from list box?????
OK, I'm feeling really stupid. I'm using the VB.net ListBox control and I want to get the text of selected items listed in the ListBox, but I can't figure out which property or function can do that (looking for equililant to ListBox.List(Index) in VB 6.0) I've tried ListBox.GetItemText - doesn't work. Also tried ListBox.Items.[Everything] - doesn't work. And I've tried a number of other things including Help. Anybody know how I can do this?
Many Thanks...
Darrin@CB69
-----------------------------------------------
Arrogance kills brain cells
-----------------------------------------------
Private Sub Sandwich (big As Byte)
On Error GoTo Pub
-
Feb 6th, 2002, 12:57 PM
#2
Frenzied Member
Took me a while to figure out too:
here is the code
Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MessageBox.Show(Convert.ToString(ListBox1.SelectedItem))
End Sub
Dont gain the world and lose your soul
-
Feb 6th, 2002, 12:59 PM
#3
Hyperactive Member
VB Code:
Dim intX As Int32
For intX = 0 To ListBox1.Items.Count - 1
MsgBox(ListBox1.Items.Item(intX), MsgBoxStyle.Information)
Next
-
Feb 6th, 2002, 02:33 PM
#4
Thread Starter
Lively Member
Thanks guys. Strange they made that one so abstract.
Darrin@CB69
-----------------------------------------------
Arrogance kills brain cells
-----------------------------------------------
Private Sub Sandwich (big As Byte)
On Error GoTo Pub
-
Feb 7th, 2002, 03:43 AM
#5
I think this is because a listbox can now contain any object that has a ToString method.
If I did understand this correctly:
Because the Object class itselve provides a ToString method, and every object inherits from the Object class, the only objects that do not qualify would be the ones that override the ToString method PRIVATE.
Of course not every object would give the desired results, because the return value of the ToString method will be displayed in the listbox.
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
|