vb.net - Listview item compare -


i've tried know , couldn't make work.

if listview.item(1) item.text has same listview.item(0) item.text can count them , make 2xitem.text?

example:

listview

coke
coke
7up

2x coke 1x 7up

you can use dictionary help. create dictionary of string , int update , insert accordingly.

dim itemdictionary new dictionary(of string, integer) each item listviewitem in listview1.items     'loop through item in listview     dim previousvalue integer     if (itemdictionary.trygetvalue(item.text, previousvalue))         'if can value add 1 previous value         itemdictionary(item.text) = previousvalue + 1     else         'if cant value = not found, add new         itemdictionary.add(item.text, 1)     end if next 

to access value dictionary, use value , key

for each item in itemdictionary     console.writeline(string.format("{0}x {1}", item.value, item.key)) next 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -