• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
猩球崛起
积小成多
博客园    首页    新随笔    联系   管理    订阅  订阅
C# winform中ListView用法
            //更改属性
            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];

 

posted on 2013-04-12 22:56  Orangutan  阅读(364)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3