如何在listview中设置组头不可选?

我需要一些帮助我的listview元素,我想使用listview与组。 但我想让组头不可选,我想用它们作为分隔符?

我怎样才能做到这一点?


我添加了this.lstView.SelectedIndexChanged事件监听器。 此外,我有两个小组,我需要每个项目的每个索引。 如果我使用((ListViewItem)lstView.SelectedItems[0]).Index调试索引((ListViewItem)lstView.SelectedItems[0]).Index事件监听器中的((ListViewItem)lstView.SelectedItems[0]).Index如果选择了组标题,我会收到exception,因此我想禁用组标题的选择。

解:

alt text http://sofzh.miximages.com/c%23/IC16066.gif

 // Adds a new group that has a left-aligned header listView1.Groups.Add(new ListViewGroup("List item text", HorizontalAlignment.Left)); 

您可以在http://msdn.microsoft.com/en-us/library/ezh1batz.aspx上找到有关它的更多信息。