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];
復制代碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM