Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help needed on cloning a listview 1

Status
Not open for further replies.

jisaacson

Programmer
Mar 21, 2005
14
US
There was a question back in Dec 05 about cloning a listview. This was thread thread796-1169523.

The code was as follows:
Dim itm As ListViewItem

For Each itm In ListView1.SelectedItems
Dim newitm As ListViewItem = itm.Clone
ListView2.Items.Add(newitm)
Next

When I tried this using vb2008 I get the following message:
Option strict on disallows implicit conversions from 'Object' to 'Systems.Windows.Forms.ListViewItem'

How do I modify the code to work with vb2008?

 
Try the following:

Code:
        Dim itm As ListViewItem

        For Each itm In ListView1.SelectedItems
            Dim newitm As ListViewItem = [b]CType(itm.Clone, ListViewItem)[/b]
            ListView2.Items.Add(newitm)
        Next

You probably have Option Strict On .
 
This works.

I had option strict on but reset every one I could find to option strick off and still got the same message.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top