Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have a listbox with a datasource and a display member, and i have found out that because of the data source, calling

Listbox1.SelectedItem.tostring

will always return

System.Data.DataRowView

 

So, how can i code this so it returns the test of the selecteditem?

Edited by KingAce
Posted
I'm sure you looked at the help topic for the members of the DataRowView class, so I'll assume that you just missed the bit that matters. A DataRowView is very similar to a DataRow, and it has an Item property that behaves the same way. You would thus cast the selected item as a DataRowView and then get the field item you want:
DirectCast(Me.ListBox1.SelectedItem, DataRowView).Item("test")

or, since Item is the default property, simply

DirectCast(Me.ListBox1.SelectedItem, DataRowView)("test")

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...