public TreeNode FindExistingDateNode(TreeNodeCollection nodes, string dateString) { foreach (TreeNode n in nodes) { if (n.Text == CalendarType.returnConciseGivenDate(dateString)) { return(n); } } return(null); }
public void AddNoteToTree(Note noteToAdd, int campNum, ref int noteNum) { string noteDate = noteToAdd.Date.ToString(); // Find existing date node checks if there is already a note with that same date, so it can be put in that node TreeNode existingNode = FindExistingDateNode(campaignTree.Nodes[campNum].Nodes, noteDate); if (existingNode != null) { existingNode.Nodes.Add(new TreeNode(noteToAdd.NoteContent)); } else { campaignTree.Nodes[campNum].Nodes.Add(new TreeNode(CalendarType.returnConciseGivenDate(noteToAdd.Date))); // ADD DATE OF NOTE campaignTree.Nodes[campNum].Nodes[noteNum].Nodes.Add(new TreeNode(noteToAdd.NoteContent)); // ADD NOTE CONTENT UNDER IT noteNum++; } }