this.listView1.GridLines = true; //显示表格线
this.listView1.View = View.Details;//显示表格细节
this.listView1.LabelEdit = true; //是否可编辑,ListView只可编辑第一列。
this.listView1.Scrollable = true;//有滚动条
this.listView1.HeaderStyle = ColumnHeaderStyle.Clickable;//对表头进行设置
this.listView1.FullRowSelect = true;//是否可以选择行
//this.listView1.HotTracking = true;// 当选择此属性时则HoverSelection自动为true和Activation属性为oneClick
//this.listView1.HoverSelection = true;
//this.listView1.Activation = ItemActivation.Standard; //
//添加表头
this.listView1.Columns.Add("", 0);
this.listView1.Columns.Add("列1",80);
this.listView1.Columns.Add("列2", 160);
//添加各项
ListViewItem[] p = new ListViewItem[2];
p[0] = new ListViewItem(new string[] { "","aaaa","bbbb"});
p[1] = new ListViewItem(new string[] { "","cccc", "ggggg" });
//p[0].SubItems[0].BackColor = Color.Red; //用于设置某行的背景颜色
this.listView1.Items.AddRange(p);
//也可以用this.listView1.Items.Add();不过需要在使用的前后添加Begin... 和End...防止界面自动刷新
// 添加分组
this.listView1.Groups.Add(new ListViewGroup("tou"));
this.listView1.Groups.Add(new ListViewGroup("wei"));
this.listView1.Items[0].Group = this.listView1.Groups[0];
this.listView1.Items[1].Group = this.listView1.Groups[1];

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)