private void populateActivityTree() { string errorMsg = String.Empty; activityTreeView.Nodes.Clear(); DateTime date = DateTime.Now; DateTime.TryParse(ActivitySearch.Text, out date); if (date < new DateTime(1900, 1, 1)) { date = DateTime.Now; } List <Activity> acvityList = Controller.GetActivityList(date, out errorMsg); TreeNode node = new TreeNode(); foreach (Activity act in acvityList) { node = new TreeNode(); node.Text = act.ActivityTypeName; node.Tag = act; activityTreeView.Nodes.Add(node); } }