|
-
Sep 7th, 2010, 08:37 PM
#13
Thread Starter
Lively Member
Re: reading an individual field
 Originally Posted by jmcilhinney
No, it doesn't have to do with those two lines. Those two lines control how the bound ListBox behaves. DisplayMember is the name of the property or column whose data should be displayed, hence you see the Name values in the ListBox. ValueMember is the name of the property or column whose data should be exposed via the SelectedValue, hence when the user selects a Name you can get the corresponding Filepath from the SelectedValue of the ListBox.
If you wanted to do things the hard way, you could handle the SelectedIndexChanged event of the ListBox, get the SelectedValue and then display that in the Label. If you've already bound the ListBox though, it's only logical to bind the Label as well. Instead of assigning the array to the DataSource of the ListBox directly, assign it to a variable first. You can then bind it to both the ListBox and the Label:
vb.net Code:
Dim items = (From ...).ToArray()
ListBox1.DataSource = items
Label1.DataBindings.Add("Text", items, "Filepath")
Once bound, the Label will always display the Filepath of the item selected in the ListBox.
Okay that makes some more sense, thank you. So for example if i added Subject= to the text string
Filepath=filepath1::Name=name1::Subject=subject1
i could have a second label and do
vb.net Code:
label2.databindings.add("Text", items, "Subject")
and for the other code
vb.net Code:
Select New With {.filepath = parts(0).Split("="c)(1), .Name = parts(1).Split("="c)(1), .Subject = parts(2).Split("="c)(2)}).ToArray()
Correct?
Thank you so much for your help and time!
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
|