Don't understand BindingSource.Item(0).Row(0)

H

HONOREDANCESTOR

I have a book on vb.net that came out in 2006. It uses properties and
methods that I can't find in documentation. For instance, it has a
line such as:
MyBindingSource.Item(0).Row(0).
What is Item zero, and what is Row zero of that item?
In another section, the book has a listbox on a form, and there too it
uses a Row property as follows:
MyListBox.SelectedItem.Row(1)
Why would a selected item in a listbox have rows? If a listbox
contains both a hidden value and a displayed string, isn't there a
better way to get the displayed string?
Thanks,
HA
 
G

Guest

In this context, MyBindingSource is a Dataview

MyBindingSource.Item(0).Row(0)...is confusing because of the row property...
The Item is the row of the Dataview, and the Row is the underlying DataRow,
and (0) is the first column in that DataRow.

The second question depends on the framework you are using.

MyListBox.SelectedItem is an object that you can cast as a ListViewItem.
Search ListView and ListViewItem and look at the properties on MSDN.

In framework 1.0, the ListViewItem has a subitem property...
Dim LVI as ListViewItem = ListBox1.SelectedItem
dim Key as string = LVI.subitem(0).Text 'assuming the Key is in column 0 of
the datasource
dim Value as string = LVI.subitem(1).Text
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top