views:

156

answers:

2

Hai,

I tried to create a ListViewControl (tile mode) and added a ListViewItem. I created it like this,

ListViewItem aFooItem = new ListViewItem("foo");
listView1.Items.Add(aFooItem);  //Adding the ListViewItem to the ListViewControl

Now I ran the application and tried to debug the first line. I found that the aFooItem's subitems count is 1 and is similar to aFooItem itself. Could somebody help me why the aFooItem's SubItems.Count is 1, even thou' I didn't add an item to it explicitly ??

+1  A: 

A ListViewItem's "SubItems" is the list of columns it contains. By initializing your ListViewItem with a default string ("foo") you've added one subitem (with Text == "foo").

Matt Hamilton
+1  A: 

The default value of a ListViewItem is the value of the sub-item at index 0. When you create a ListViewItem it automatically creates the default sub-item for you.

Sarcastic