C# ListView Control
The ListView control is an ItemsControl that is derived from ListBox.
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.
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.
Get selected item from ListView
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:
Add Checkbox in Listview
You can add checkbox in Listview columns.
ListView provides a large number of properties that provide flexibility in appearance and behavior. The View property allows you to change the way in which items are displayed. The SelectionMode property for a ListView determines how many items a user can select at one time.
The following C# program first set its view property as Details and GridLines property as true and FullRowSelect as true.
Finally at the button click event, it will display the selected row values in a message box.
Full Source C#- C# Visual Studio IDE
- How to Create a C# Windows Forms Application
- C# Label Control
- C# Button Control
- C# TextBox Control
- C# ComboBox
- C# ListBox Control
- C# Checked ListBox Control
- C# RadioButton Control
- C# CheckBox Control
- C# PictureBox Control
- C# ProgressBar Control
- C# ScrollBars Control
- C# DateTimePicker Control
- C# Treeview Control
- C# Menu Control
- C# MDI Form
- C# Color Dialog Box
- C# Font Dialog Box
- C# OpenFile Dialog Box
- C# Print Dialog Box
- keyPress event in C# , KeyDown event in C# , KeyUp event in C#
- How to create Dynamic Controls in C# ?
- Keep Form on Top of All Other Windows
- C# Timer Control