private void DisplayTableWithListview()
{
listView1.GridLines = true;// Whether the grid lines are displayed
listView1.FullRowSelect = true;// Whether to select the entire line
listView1.View = View.Details;// Set display mode
listView1.Scrollable = true;// Whether to show the scroll bar automatically
listView1.MultiSelect = false;// Is it possible to select multiple lines
// Add header(column)
listView1.Columns.Add("ToString(yyyyMMddHHmm)", 160, HorizontalAlignment.Center);
// Add items into table
for (int i = 0; i < 6; i )
{
ListViewItem item = new ListViewItem();
item.SubItems.Clear();
item.SubItems[0].Text = "Product" i.ToString();
item.SubItems.Add(i.ToString());
item.SubItems.Add((i 7).ToString());
item.SubItems.Add((i * i).ToString());
listView1.Items.Add(item);
}
}
Product0 is in the cell/place of the column header. i want the items to be start added from the second cell.
CodePudding user response:
you can use listView1.Items.Insert(index , item)
to add item in specialty index.