要在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);