要在C#中為ListView添加自定義列,可以通過以下步驟實現:
// 添加列頭
listView1.Columns.Add("Column1", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Column2", 100, HorizontalAlignment.Left);
listView1.Columns.Add("Column3", 100, HorizontalAlignment.Left);
// 添加數據
string[] row1 = { "Item1-1", "Item1-2", "Item1-3" };
string[] row2 = { "Item2-1", "Item2-2", "Item2-3" };
ListViewItem item1 = new ListViewItem(row1);
ListViewItem item2 = new ListViewItem(row2);
listView1.Items.Add(item1);
listView1.Items.Add(item2);