1

Now, I know how to add SubItems, but this time it's slightly different from my usual method. below is what I'm using to add items to my listview, however using this I cannot figure out how to add subitems.

listView1.Items.Add(Path.GetFileName(f));
Lane will
  • 75
  • 9
  • Path.GetFileName() returns a string. Does listView1.Items hold string values? I would think it holds some sort of listitem object – Anthony McGrath Sep 03 '17 at 04:36
  • Do you want to get list of filename inside a directory and put them into listview items? – Ali Adlavaran Sep 03 '17 at 04:40
  • @AnthonyMcGrath Well no, `ListView.ListViewItemCollection` does have an add method for strings https://msdn.microsoft.com/en-us/library/ttzhk9y3(v=vs.110).aspx –  Sep 03 '17 at 04:42

1 Answers1

0

Try this:

listView1.Items.Add(Path.GetFileName(f));

listView1.Items[0 /* or any index you need */].SubItems.Add("SubItem");
Anthony McGrath
  • 792
  • 5
  • 7