private void cmdApplyFilter_Click(object sender, EventArgs e) { var sortInfo = GetSortInfo(dgvTexts); IEnumerable <CustomTextViewModel> texts = _textsVM; if (cmbProfileType.SelectedIndex > 0) { string typProf = (string)cmbProfileType.SelectedItem; texts = texts.Where(t => t.TypProf == typProf || string.IsNullOrEmpty(t.TypProf)); } if (cmbLanguage.SelectedIndex > 0) { Language lang = (Language)cmbLanguage.SelectedItem; texts = texts.Where(t => t.LangID == lang.LangID); } if (cmbReportKeys.SelectedIndex > 0) { string reportKey = (string)cmbReportKeys.SelectedItem; texts = texts.Where(t => t.ReportKey == reportKey); } if (!rbAllTexts.Checked) { bool isHeader = rbHeaderTexts.Checked; texts = texts.Where(t => t.IsHeader == isHeader); } if (chkAutoTexts.Checked) { texts = texts.Where(t => t.Optional == false); } if (chkOptTexts.Checked) { texts = texts.Where(t => t.Optional == true); } SimpleSortableBindingList <CustomTextViewModel> sortableList = new SimpleSortableBindingList <CustomTextViewModel>(texts); bsTexts.DataSource = sortableList; TrySetSortInfo(dgvTexts, sortInfo); }
private void BindAllTexts() { SimpleSortableBindingList <CustomTextViewModel> sortableList = new SimpleSortableBindingList <CustomTextViewModel>(_textsVM); bsTexts.DataSource = sortableList; }