|
-
February 2nd, 2012, 04:20 PM
#1
e.Item.SubItems[0].Text from a listview ItemCheckedEventArgs object
Hello
I'm trying to copy info from one two-column listview control to another when the checkbox is selected.
listViewPlayerList contains a list of footballers, their country flag, and a value (as well as a checkbox)
I've set up a listViewPlayerList_ItemChecked(object sender, ItemCheckedEventArgs e) event to check for the box being checked...no problem there.
I then (among various other things) attempt to copy the info stored in "e" into a new ListViewItem called selectedPlayerInList, and a new ListViewItem.ListViewSubItem called selectedPlayerValue
I do this with these three lines of code
selectedPlayerInList.ImageIndex = e.Item.ImageIndex; // copies the flag
selectedPlayerInList.Text = e.Item.Text; // copies the player's name
selectedPlayerValue.Text = e.Item.SubItems[0].Text; // copies his value
The two lines copying into selectedPlayerInList work absolutely fine.
The copying into selectedPlayerValue doesn't work though.
e.Item.SubItems[0].Text returns the same text as e.Item.Text.
the graphic below is an example...
I've seleced Iker Casillas as my goalkeeper, and rather than copying across "£4m", it's copied "Iker Casillas" again. And I have checked by displaying the value of e.Item.SubItems[0].Text, and that's what it contains.

(ignore the other players that look to be working. I set those up as default values)
I am something of a C# newbie, just studying from home, so I think I may have made some kind of schoolboy error, but I can't see where.
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
|