C# winform中ListView用法

來源:互聯網
上載者:User
            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]; listview,怎麼也沒找到從那個地方調整item的行高, 找來找去也沒發現,真想大罵微軟一下,仔細思考一下,因該有2種方式,一種重寫listview,另外一種listview肯定有相關屬性來調整行高,功夫不負有心人。網上有個寫高人,通過如下方式來實現1,添加一imagelist控制項2,指定listview的smallimages屬性為imagelist13,只需要調整imagelist中映像高度.listview控制項中的高度隨之調整。非常簡單的小問題

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.