public void SetJournal(studentsgroup gr) { this.RemoveJournal(); this.grid1.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); int cnt = gr.students.Count; for (int i = 0; i < cnt + 1; i++) { this.grid1.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } this.tableHeader = new JournalTableHeader(); this.tableHeader.OnSelectedSubjectChanged += this.Handler_SelectedSubjectChanged; this.tableHeader.OnSelectedMonthChanged += this.Handler_SelectedMonthChanged; Grid.SetColumn(this.tableHeader, 0); Grid.SetRow(this.tableHeader, 0); this.grid1.Children.Add(this.tableHeader); this.tableHeader.SetData(gr); var coll = from s in gr.students orderby s.person.Last_Name select s; int num = 0; foreach (var st in coll) { JournalRowHeader rh = new JournalRowHeader(); rh.SetData(st); this.rowHeaders.Add(rh); Grid.SetColumn(rh, 0); Grid.SetRow(rh, ++num); this.grid1.Children.Add(rh); } this.tbTopic.IsReadOnly = !this.IsEditable; this.tbTask.IsReadOnly = !this.IsEditable; this.btnTask.IsEnabled = this.IsEditable; this.btnTopic.IsEnabled = this.IsEditable; }
void RemoveJournal() { this.tableHeader = null; this.grid1.Children.Clear(); this.rowHeaders.Clear(); this.columnHeaders.Clear(); this.tbTask.Text = ""; this.tbTopic.Text = ""; GC.Collect(); }