private void PopulateTreeView() { using (var context = new DiagnosoftContext()) { var q = (from i in context.Patients group i by i.Date into grpDate select grpDate); foreach (var item in q) { TreeNode nodes = new TreeNode(q.ToString()); //Create root node first TreeNode tn = item as TreeNode; var childNodes = q; //Next sub-query to be write foreach (var child in childNodes) //Adding child nodes to root node if it have any { TreeNode childNode = new TreeNode(q.ToString()); nodes.Nodes.Add(childNode); } treePatient.Nodes.Add(nodes); //At the last add the root node with child nodes to treeview } } } public class Patient { public int PatientId { get; set; } public int RegisteredNo { get; set; } public DateTime Date { get; set; } public string PatientName { get; set; } public int Age { get; set; } public int Sex { get; set; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)