In VB.net (2012) I have the following code:
For Each itm As ListViewItem In Me.lvCustomers
If CDbl(itm.Tag) <> customer.Id Then Me.lvMerges.Items.Add(itm.Clone)
Next
With Option Strict On I get the following error:
Error 2 Overload resolution failed because no accessible 'Add' can be called with these arguments: 'Public Overridable Function Add(value As System.Windows.Forms.ListViewItem) As System.Windows.Forms.ListViewItem': Option Strict On disallows implicit conversions from 'Object' to 'System.Windows.Forms.ListViewItem'. 'Public Overridable Function Add(text As String) As System.Windows.Forms.ListViewItem': Option Strict On disallows implicit conversions from 'Object' to 'String'.
I can do an lvMerges.Items.Add(itm) , which does not throw an error, but then I have to remove it from the lvCustomers listview, which I do not want to do.
Can someone explain how I can make this work properly without turning off Option Strict?
Goal is to copy ListviewItem with all SubItems.