如何在ListView上实现多个列标题? [英] How to implement multiple column headers on ListView?
问题描述
就像在图片上一样,下面有第二列标题和两个子标题吗?
Like on the pic, there is second column header and two subheaders under it ?
推荐答案
有关此示例的完整示例,应该为您提供一个完整的可行示例 添加ListView列并插入Listview项
For a complete example look at this link this should give you a full working example of what you can do Add ListView Column and Insert Listview Items
尝试这样的事情
将值添加到数组的顺序决定了它们显示在其下的列,因此请考虑子项标题为[0],
The order in which you add values to the array dictates the column they appear under so think of your sub item headings as [0],1 etc.
这是一个代码示例:
//在此示例中,将三项数组添加到三列列表视图中 string [] saLvwItem = new string [2];
//In this example an array of three items is added to a three column listview string[] saLvwItem = new string[2];
foreach (string wholeitem in listofitems)
{
saLvwItem[0] = "Status Message";
saLvwItem[1] = wholeitem;
ListViewItem lvi = new ListViewItem(saLvwItem);
lvwMyListView.Items.Add(lvi);
}
要添加子项,您还可以执行以下操作
To add SubItems you could also do something like this
lvwMyListView.Items[0].SubItems.Add("John Smith");
这篇关于如何在ListView上实现多个列标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!