Reputation: 3
So I have the following code:
listView1.Items.Add("Test");
ListViewItem testing = new ListViewItem();
testing.SubItems.Add("Test2");
listView.Items.Add(testing);
And here's what it produces:
(source: gyazo.com)
Not sure why the "Test2" goes at the bottom.
Upvotes: 0
Views: 139
Reputation: 147
First of all Both list view are same listView1 and listView? If yes then here is the Answer:
listView1.Items.Add("Test"); while wrting this line of code you are adding first item in List view with main item "Test" and all subitems empty.
listView.Items.Add(testing); After doing this you are adding second item in the list view with main item Empty and first subitem as "Test2"
To add one item in listView with subitem try this:
ListViewItem testing = new ListViewItem();
testing.Text="Test";
testing.SubItems.Add("Test2");
listView.Items.Add(testing);
Upvotes: 0