How to implement multiple column headers on ListView?

纵然是瞬间 提交于 2019-12-13 22:09:33

问题


Like on the pic, there is second column header and two subheaders under it ?


回答1:


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

try something like this

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.

Here's a code sample:

//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");


来源:https://stackoverflow.com/questions/12080614/how-to-implement-multiple-column-headers-on-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!