ListView Control in C#.Net

A ListView control allows to display a list of items. ListView is very similar to windows explorer. In ListView you can list the items in list view, icon view, detail view.

How to use ListView Control

Drag and drop ListView control from toolbox on the WindowForm.

ListView Control in C#.Net

Code:

using System;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsApplication1

{

    public partial class frmListView : Form

    {

        public frmListView()

        {

            InitializeComponent();

        }

        private void frmListView_Load(object sender, EventArgs e)

        {

            //specify which view should display of listview Item

            listView1.View = View.Details;

            // add columns in ListView

            listView1.Columns.Add("Emp Id", 100, HorizontalAlignment.Left);

            listView1.Columns.Add("Emp Name", 100, HorizontalAlignment.Left);

            // add Items in ListView

            listView1.Items.Add("UMS101").SubItems.Add("Yash");

            listView1.Items.Add("UMS102").SubItems.Add("Raj");

        }

    }

}

 Run the project

ListView Control in C#.Net

You can change its view in details,LargeIcon,SmallIcon,Tile,List  through its view property.

When you set   listView1.View = View.Tile;   then listview data will show in Tile View.

ListView Control in C#.Net

ListView Properties:

View:  Defines how items are displayed in the control.

CheckBoxes:  Indicates whether a check box appears next to each item in the control.

Example:

private void frmListView_Load(object sender, EventArgs e)

{

           // appears checkBox next to each Item

           listView1.CheckBoxes = true;

}

 Output

CheckBox will appear  when the application run.

ListView Control in C#.Net

TileSize:  Defines the size of the tiles shown in tile view.

BackColor:  Set BackColor of ListView.

Example:

private void frmListView_Load(object sender, EventArgs e)

{

           // Change BackColor Of ListView

           listView1.BackColor = Color.CadetBlue;

 }

ListView Control in C#.Net

回答: 在C#中,ListView控件可以显示多行多列信息,类似于Excel表格。而且,ListView控件可以在每一行前面添加Checkbox复选框,并且实现复选框的多选功能。\[1\]如果你想要实现ListView中的所有复选框都被选中或取消选中,你可以使用以下两种方法之一。方法一是使用循环遍历ListView中的每一项,并设置每一项的Checked属性为true或false来实现全选或全不选的功能。\[2\]方法二是在点击一个按钮时,使用循环遍历ListView中的每一项,并将每一项的Checked属性设置为false来取消选中。\[3\]这样就可以实现ListView中的多复选框功能。 #### 引用[.reference_title] - *1* [C#实现ListView控件的Checkbox复选框多选](https://blog.csdn.net/GL3_24/article/details/90547188)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [【转载】C# ListView控件的一些用法](https://blog.csdn.net/weixin_42946900/article/details/114915511)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [C#-带复选框的ListView](https://blog.csdn.net/dxm809/article/details/91788203)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值