C# ListView分组显示的编程方法(listveiwgroup)
XP以后的操作系统,开始支持ListView的分组显示,本例的测试截图如下:http://p.blog.csdn.net/images/p_blog_csdn_net/blog51/listviewgroup01.jpg
http://p.blog.csdn.net/images/p_blog_csdn_net/blog51/listviewgroup02.jpg
主要代码如下:
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifprivatevoidbutton1_Click(objectsender,EventArgse)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.Groups.Clear();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.Items.Clear();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.View=View.LargeIcon;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifColumnHeadercolumnHeader0=newColumnHeader();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader0.Text="Title";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader0.Width=200;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifColumnHeadercolumnHeader1=newColumnHeader();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader1.Text="Author";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader1.Width=200;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifColumnHeadercolumnHeader2=newColumnHeader();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader2.Text="Year";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifcolumnHeader2.Width=100;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.giflistView1.Columns.AddRange(newColumnHeader[]...{columnHeader0,columnHeader1,columnHeader2});
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewGroupgroup1=newListViewGroup("001");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewGroupgroup2=newListViewGroup("002");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.Groups.Add(group1);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.Groups.Add(group2);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif//CreateitemsandaddthemtomyListView.
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem0=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"ProgrammingWindows",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Petzold,Charles",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"1998"},0,group1);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem1=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"Code:TheHiddenLanguageofComputerHardwareandSoftware",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Petzold,Charles",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"2000"},0,group1);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem2=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"ProgrammingWindowswithC#",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Petzold,Charles",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"2001"},0,group1);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem3=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"CodingTechniquesforMicrosoftVisualBasic.NET",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Connell,John",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"2001"},1,group2);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem4=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"C#forJavaDevelopers",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Jones,Allen&Freeman,Adam",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"2002"},1,group2);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifListViewItemitem5=newListViewItem(newstring[]
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{"Microsoft.NETXMLWebServicesStepbyStep",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif"Jones,Allen&Freeman,Adam",
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif"2002"},1,group2);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.Items.AddRange(
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gifnewListViewItem[]...{item0,item1,item2,item3,item4,item5});
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifprivatevoidbutton2_Click(objectsender,EventArgse)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giflistView1.View=View.Details;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
页:
[1]