C#之常用控件集合(英文版)

刚刚在找关于ListView的资料,意外的发现了这个网站:http://csharp.net-informations.com/gui/cs-listview.htm上面列举了很多C#常见控件的使用。C# ListView ControlThe ListView control is an ItemsControl that is derived from Li
摘要由CSDN通过智能技术生成

The ListView control is an ItemsControl that is derived from ListBox.

C# listview

Add Columns in ListView

You can add columns in Listview by using Columns.Add() method. This method takes two arguments, first one is the Column heading and second one the column width.

listView1.Columns.Add("ProductName", 100);

In the above code, "ProductName" is column heading and 100 is column width.

Add Item in Listview

You can add items in listbox using ListViewItem which represents an item in a ListView control.

    string[] arr = new string[4];    ListViewItem itm;//add items to ListView    arr[0] = "product_1";    arr[1] = "100";    arr[2] = "10";    itm = new ListViewItem(arr);    listView1.Items.Add(itm);

Get selected item from ListView

productName = listView1.SelectedItems[0].SubItems[0].Text;

Above code will return the itme from first column of first row.

Sorting Listview Items

If the Sorted property of Listview is set to true, then the ListView items are sorted. The following code sorts the ListView items:

ListView1.Sorted = true;

Add Checkbox in Listview

You can add checkbox in Listview columns.

myListView.CheckBoxes = true;myListView.Columns.Add(text, width, alignment);

C# Listview example

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值