ListView Control in C#

Create New Project and give the Name of the project is ListViewTutorial. Add the textbox1.text,textbox2.text,command button and ListView control and copy this code and paste. 


usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceListViewTutorial
{
    public partial class Form1 : Form
    {
        publicForm1()
        {
            InitializeComponent();
        }
        privatevoid Form1_Load(objectsender, EventArgs e)
        {
            listView1.GridLines = true;
            listView1.View = View.Details;
            //Add Column Header
            listView1.Columns.Add(“Employee ID”, 150);
            listView1.Columns.Add(“Employee Name”, 150);
        }
        privatevoid button1_Click(objectsender, EventArgs e)
        {
            // Add item in the Listview
            ListViewItemlv = new ListViewItem(textBox1.Text);
            lv.SubItems.Add(textBox2.Text);
            listView1.Items.Add(lv);
        }
    }
}

  


0 Comments on “ListView Control in C#”

Leave a Reply

Your email address will not be published. Required fields are marked *