嗨,我遵循了填充列表视图的答案,但是列表视图是水平填充的,但我需要按列填充它,这是我的代码
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);
}
输出如下:
CODE 1 2
NAME x y
ORDERS 4 4
...
但我想要它
CODE NAME ORDERS ...
1 x 4
2 y 4
我该怎么做?