[code]private void MainTimesheetForm_Load(object sender, EventArgs e)
{
ListViewItem newList = new ListViewItem("RN", 0);
newList.SubItems.Add("2");
newList.SubItems.Add(DateTime.Now.ToLongTimeString());
newList.SubItems.Add("3");
newList.SubItems.Add("4");
newList.SubItems.Add("5");
newList.SubItems.Add("6");
listViewTimeSheet.Items.Add(newList);
ListViewItem newList2 = new ListViewItem("items", 1);
newList.SubItems.Add("2");
newList.SubItems.Add(DateTime.Now.ToLongTimeString());
newList.SubItems.Add("3");
newList.SubItems.Add("4");
newList.SubItems.Add("5");
newList.SubItems.Add("6");
listViewTimeSheet.Items.Add(newList2);
}[/code]
Please how do i add control to a subItem in listview. Thanks.
Loading
Sam HobbsPosted Apr 6, 2012, 7:25 PM
Assuming you are asking about a Windows Forms application, the ListView control is quite old. It was initially developed for the Windows Explorer accessory in Windows 95. It is less flexible than the newer controls.
VulpesPosted Apr 6, 2012, 5:52 AM
SenthilkumarPosted Apr 5, 2012, 9:44 PM
Are you talking about ListView in asp.net or ListBox in asp.net?
Because you can't add the items like this in ListView control.
If you want to implement like this then you can go for
TreeView
or
Nested DataControls
I have written two articles for nested data controls and treeview.
http://www.c-sharpcorner.com/uploadfile/skumaar_mca/nested-data-controls-in-Asp-Net/
http://www.c-sharpcorner.com/UploadFile/skumaar_mca/tree-view-control-with-an-example/