SoFunction
Updated on 2025-04-06

ListView control implementation form code in C#

I won’t say much nonsense, I will just post the key code to you.

The specific code is as follows:

using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//Set the imagelist associated with the listview = imageList2;
 = imageList1;
//Show details = ;
//Add groupListViewGroup lg1 = new ListViewGroup();
 = "A group";
 = "one";
(lg1);
ListViewGroup lg2 = new ListViewGroup();
 = "Two Groups";
 = "two";
(lg2);
//Add column("Code name");
("Name");
("Birthday");
//Select the entire line = true;
//Show checkbox = true;
//Add item, each piece of data on listview is called an itemInfoDA da = new InfoDA();
List<Info> list = ();
foreach (Info data in list)
{
//Master itemListViewItem zhuxiang = new ListViewItem();
 = ;
 = 0;
 = [0];
//Make a child zi1 = new ();
 = ;
(zi1);
 zi2 = new ();
 = ("yyyy-MM-dd"); ;
(zi2);
//Add Item(zhuxiang);
}
foreach (Info data in list)
{
//Master itemListViewItem zhuxiang = new ListViewItem();
 = ;
 = 1;
 = [1];
//Make a child zi1 = new ();
 = ;
(zi1);
 zi2 = new ();
 = ("yyyy-MM-dd"); ;
(zi2);
//Add Item(zhuxiang);
}
}
private void button1_Click(object sender, EventArgs e)
{
 = ;
}
private void button2_Click(object sender, EventArgs e)
{
 = ;
}
private void button3_Click(object sender, EventArgs e)
{
 = ;
}
private void button4_Click(object sender, EventArgs e)
{
if ( > 0)
{
([0].Text);
}
}
private void button5_Click(object sender, EventArgs e)
{
// = true;
}
private void button6_Click(object sender, EventArgs e)
{
string s = "";
foreach (ListViewItem item in )
{
s += +"--";
}
(s);
}
}
}

The above is the code of the ListView control implementation form in C# introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!