Tuesday, December 6, 2011

C# ListViews

Creating the view, adding grid lines and columns..
listView1.View = View.Details;
listView1.GridLines = true;

listView1.Columns.Add("ID");
listView1.Columns.Add("First Name", 90);
listView1.Columns.Add("Last Name", 80);
listView1.Columns.Add("DOB");
 After adding columns you can add data..
ListViewItem item = new ListViewItem();
item.Text = "0";
item.SubItems.Add("John");
item.SubItems.Add("Doe");
item.SubItems.Add("12/14/81");

listView1.Items.Add(item);
 Now you can set a full row select, a popular feature..
listView1.FullRowSelect = true;

No comments:

Post a Comment