// Отменить поиск. Обработка события нажатия на кнопку. private void tbSearchCancel_Click(object sender, EventArgs e) { IDataSourceView students = this.ActiveMdiChild as DataViewForm <IStudent>; IDataSourceView companies = this.ActiveMdiChild as DataViewForm <ICompany>; IDataSourceView form = students ?? companies; if (form == null) { return; } form.SetDataSourceFilter(null); }
// Поиск. Обработка события нажатия на кнопку. private void btnSearch_Click(object sender, EventArgs e) { IDataSourceView students = this.ActiveMdiChild as DataViewForm <IStudent>; IDataSourceView companies = this.ActiveMdiChild as DataViewForm <ICompany>; IDataSourceView form = students ?? companies; if (form == null) { return; } var filter = students == null ? $"([Название] LIKE '%{tbSearch.Text}%')" : BuildStudentSearchString(); form.SetDataSourceFilter(filter); }