Hi I followed the answers to populating the listview, but the list view is populated horizontally but rather i need it to be populated column wise here's my code
listView1.Items.Clear();
listView1.Columns.Clear();
Dictionary<string, List<string>> Values = new Dictionary<string, List<string>>();
Values.Add("CODE", list_p_code);
Values.Add("NAME", list_p_name);
Values.Add("MRP", list_mrp);
Values.Add("ORDERS", list_order_qty);
Values.Add("PENDING", list_variance_qty);
foreach (string key in Values.Keys)
{
listView1.Columns.Add(key, -2,HorizontalAlignment.Left);
// Fill item
ListViewItem item = new ListViewItem(key);
// Fill Sub Items
List<string> list = Values[key];
foreach (string data in list)
{
item.SubItems.Add(data.ToString());
}
// Add to the ListView
listView1.Items.Add(item);
}
The output is as follows:
CODE 1 2
NAME x y
ORDERS 4 4
...
but I want it as
CODE NAME ORDERS ...
1 x 4
2 y 4
How do I do it?