资源简介
解决 adapter.notifyDataSetChanged() 不起作用
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ListViewTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
///
/// 添加2个分组
///
private void AddTwoGroups()
{
ListViewGroup group1 = new ListViewGroup();
group1.Header = “默认项“;
group1.HeaderAlignment = HorizontalAlignment.Center;
ListViewGroup group2 = new ListViewGroup();
group2.Header = “添加项“;
group2.HeaderAlignment = HorizontalAlignment.Center;
this.listView1.Groups.Add(group1);
this.listView1.Groups.Add(group2);
this.listView1.ShowGroups = true;
}
private void Form1_Load(object sender EventArgs e)
{
AddTwoGroups();
this.listView1.LargeImageList = this.imageList1;
this.listView1.SmallImageList = this.imageList1;
//为“详细信息”显示方式添加列
this.listView1.Columns.Add(“列标题1“ 100 HorizontalAlignment.Left);
this.listView1.Columns.Add(“列标题2“ 100 HorizontalAlignment.Left);
this.listView1.Columns.Add(“列标题3“ 100 HorizontalAlignment.Left);
//添加项
this.listView1.Items.Add(“我的电脑“);
this.listView1.Items.Add(“我的文档“);
this.listView1.Items.Add(“我的音乐“);
//item.SubItems.Add(cb1);
//this.listView1.Items.Add(
//为“详细信息”显示方式设置列的值
for (int i = 0; i < this.listView1.Items.Count; i++)
{
int row = i + 1;
this.listView1.Items[i].SubItems.Add(“第“ + row + “行第2列“);
this.listView1.Items[i].SubItems.Add(“第“ + row + “行第3列“);
}
//添加图标
this.listView1.Items[0].ImageIndex = 0;
this.listView1.Items[1].ImageIndex = 1;
this.listView1.Items[2].ImageIndex = 2;
//将默认的3项归到“默认项”分组
this.listView1.Items[0].Group = this.listView1.Groups[0];
this.listView1.Items[1].Group = this.listView1.Groups[0];
this.listView1.Items[2].Group = this.listView1.Groups[0];
//显示方式
this.comboBox1.Items.Add(“大图标“);
this.comboBox1.Items.Add(“小图标“);
this.comboBox1.Items.Add(“详细信息“);
this.comboBox1.Items.Add(“平铺视图“);
//默认显示方式为“大图标”(第一种显示方式)
this.comboBox1.SelectedIndex = 0;
}
//添加新项
private void button1_Click(object sender EventArgs e)
{
if (this.textBox1.Text != ““)
{
this.listView1.Items.Add(this.textBox1.Text.Trim());
int count = this.listView1.Items.Cou
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5612 2015-09-21 14:07 ListViewTest\ListViewTest\Properties\Resources.resx
文件 249 2015-09-21 14:07 ListViewTest\ListViewTest\Properties\Settings.settings
文件 1376 2015-09-21 14:07 ListViewTest\ListViewTest\Properties\AssemblyInfo.cs
文件 2874 2015-09-21 14:07 ListViewTest\ListViewTest\Properties\Resources.Designer.cs
文件 1097 2015-09-21 14:07 ListViewTest\ListViewTest\Properties\Settings.Designer.cs
文件 4984 2015-09-24 15:43 ListViewTest\ListViewTest\Form1.cs
文件 10754 2015-09-24 11:07 ListViewTest\ListViewTest\Form1.resx
文件 3735 2015-09-21 14:13 ListViewTest\ListViewTest\ListViewTest.csproj
文件 490 2009-06-11 05:14 ListViewTest\ListViewTest\bin\Debug\ListViewTest.vshost.exe.manifest
文件 14328 2015-09-24 15:32 ListViewTest\ListViewTest\bin\Debug\ListViewTest.vshost.exe
文件 15360 2015-09-24 15:43 ListViewTest\ListViewTest\bin\Debug\ListViewTest.exe
文件 26112 2015-09-24 15:43 ListViewTest\ListViewTest\bin\Debug\ListViewTest.pdb
文件 3617 2015-09-21 09:36 ListViewTest\ListViewTest\bin\Debug\3.GIF
文件 5506 2015-09-21 09:35 ListViewTest\ListViewTest\bin\Debug\1.GIF
文件 4086 2015-09-21 09:36 ListViewTest\ListViewTest\bin\Debug\2.GIF
文件 3431 2015-09-24 11:07 ListViewTest\ListViewTest\obj\Debug\ListViewTest.Form1.resources
文件 180 2015-09-21 14:13 ListViewTest\ListViewTest\obj\Debug\ListViewTest.Properties.Resources.resources
文件 15360 2015-09-24 15:43 ListViewTest\ListViewTest\obj\Debug\ListViewTest.exe
文件 695 2015-09-24 15:32 ListViewTest\ListViewTest\obj\Debug\ListViewTest.csproj.FileListAbsolute.txt
文件 847 2015-09-24 11:07 ListViewTest\ListViewTest\obj\Debug\ListViewTest.csproj.GenerateResource.Cache
文件 26112 2015-09-24 15:43 ListViewTest\ListViewTest\obj\Debug\ListViewTest.pdb
文件 5932 2015-09-24 11:07 ListViewTest\ListViewTest\Form1.Designer.cs
文件 493 2015-09-21 14:07 ListViewTest\ListViewTest\Program.cs
文件 926 2015-09-21 14:07 ListViewTest\ListViewTest.sln
..A..H. 19456 2015-09-24 15:46 ListViewTest\ListViewTest.suo
目录 0 2015-09-21 14:07 ListViewTest\ListViewTest\obj\Debug\TempPE
目录 0 2015-09-24 10:33 ListViewTest\ListViewTest\obj\Debug\Refactor
目录 0 2015-09-21 14:07 ListViewTest\ListViewTest\bin\Debug
目录 0 2015-09-21 14:07 ListViewTest\ListViewTest\obj\Debug
目录 0 2015-09-21 14:07 ListViewTest\ListViewTest\Properties
............此处省略7个文件信息
评论
共有 条评论