listviewItem the only constructor?

SQLKing

New member
Joined
Apr 19, 2013
Messages
4
Programming Experience
10+
It can't be helped. I've been searching for 2 days and haven't found the answer yet. All of the examples of listviews people are creating a listviewItem and adding data to it. When I try to add a listviewItem the only constructor I get requires a type of either Data, Insert or Empty. I select Data but then I don't have the methods for adding values or subitems which all of the examples show. In fact, if I copy an example of how to build a listview verbatim I just get errors that the constructor is wrong that the methods don't exist etc. How do I get the listview item that everyone else seems to have? Here is the constructor I am using if it helps to show what is going on with my machine:
C#:
[SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]ListViewItem
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] item1 = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]ListViewItem[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]ListViewItemType[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].DataItem);[/SIZE]
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,282
Location
Sydney, Australia
Programming Experience
10+
That constructor is for an ASP.NET ListViewItem. Presumably you're looking at examples of WinForms ListViews. Web and Windows controls are quite different. Similar in many respects but very different under the hood.
 
Top Bottom