It sounds like you're asking two questions. The first is how to add
SubItems
to a
ListView
. Here's some sample code to set up a new
ListViewItem
with the following fields: Date, Time, LastName, FirstName. Notice that I didn't have the time, so I left it blank...but you still have to add something.
ListViewItem item1 = new ListViewItem("3/25/2010");
item1.SubItems.Add("");
item1.SubItems.Add("Jeffers");
item1.SubItems.Add("William");
listView1.Items.Add(item1);
As far as sorting the items based on a specific column...have a look here:
How to sort a ListView control by a column in Visual C#[
^]
It's also important to note that while the
ListViewItem
has
SubItems
, the first
SubItem
is actually the first column's value. So, if you want LastName by the order you set, you would need
SubItems[1]
.