Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.
I'm trying to grab the texts of each row of a ListView and assiging it to the
iterated tiles/buttons. The code I written unfortunately take only the last row and prints it onto all
the iterated Tiles. (the Tiles are DevExpress - third party comps. by the way. but thats not the focus here)

For example. The listview contains the following two rows (it may be more);
Name | Country | City
---------------------------
Sam  | 	Japan  | Tokyo
Dexter | Italy | Rome


thus what I seek is the ability to print onto the iterated tiles/buttons in this way:
FIRST TILE's TEXT:
Sam 
Japan
Tokyo

SECOND TILE's TEXT:
Dexter 
Italy
Rome

This is my code:
VB.NET
Dim strTileInfo As String = Nothing

    For Each tile As TileItem In TheTileControl.Items 'My iteration code through the tiles/buttons

        strTileInfo = Nothing
        tile.Text = Nothing

        'My attempt to assign each row of the ListView main item and subitem texts
        'Each row to each button
        For i = 0 To ListView.Items.Count - 1
            strTileInfo = ListView.Items(i).Text & vbCrlf & ListView.Items(i).SubItems(1).Text
            tile.Text = strTileInfo
        Next

    Next


I will be very grateful for your assistance. Thank you.
Posted
Updated 23-Jun-16 23:27pm
v2

1 solution

Try removing one of the loops e.g. (warning - untested)
VB.NET
Dim strTileInfo As String = Nothing

Dim i As Integer = 0 

 For Each tile As TileItem In TheTileControl.Items 'My iteration code through the tiles/buttons

	strTileInfo = Nothing
	tile.Text = Nothing
 
    If i < ListView.Items.Count
		strTileInfo = ListView.Items(i).Text & vbCrlf & ListView.Items(i).SubItems(1).Text
		tile.Text = strTileInfo
	End If
	i = i + 1
Next
 
Share this answer
 
Comments
SamuelDexter 26-Jun-16 20:29pm    
Works like magic! Thank you so much CHill60. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900