VB.net Option Strict, listview.items.add(itm.clone) Overload -


in vb.net (2012) have following code:

for each itm listviewitem in me.lvcustomers     if cdbl(itm.tag) <> customer.id me.lvmerges.items.add(itm.clone) next 

with option strict on following error:

error 2 overload resolution failed because no accessible 'add' can called these arguments: 'public overridable function add(value system.windows.forms.listviewitem) system.windows.forms.listviewitem': option strict on disallows implicit conversions 'object' 'system.windows.forms.listviewitem'. 'public overridable function add(text string) system.windows.forms.listviewitem': option strict on disallows implicit conversions 'object' 'string'.

i can lvmerges.items.add(itm) , not throw error, have remove lvcustomers listview, not want do.

can explain how can make work without turning off option strict?

goal copy listviewitem subitems.

the error you've received there tells option strict on on can't implicit casting object string or listviewitem. need explicit casting instead.

for each itm listviewitem in me.lvcustomers     if cdbl(directcast(itm.tag, string) <> customer.id me.lvmerges.items.add(directcast(itm.clone, listviewitem)) next 

does work?


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -