/// <summary> /// Обновить таблицу с информацией о работниках /// Пытается применить фильтр для показа /// </summary> public void UpdateInfo(string filter = "") { try { this.dataGridInfo.SelectAll(); this.dataGridInfo.ClearSelection(); List <string[]> employees = ViewEmployee.GetEmployees(filter); if (employees.Count == 0) { throw new Exception("Нет результатов поиска"); } this.dataGridInfo.RowCount = employees.Count; int currentRow = 0; foreach (string[] currentEmployee in employees) { //Добавить все элементы как текстовые for (int i = 0; i < currentEmployee.Count() - 1; i++) { this.dataGridInfo.Rows[currentRow].Cells[i].Value = currentEmployee.ElementAt(i); } //Последний элемент добавить как check-box //Создание новой ячейки-checkBox DataGridViewCheckBoxCell comboBox = new DataGridViewCheckBoxCell(); comboBox.Value = Boolean.Parse(currentEmployee.ElementAt(currentEmployee.Length - 1)); //Установить новую ячейку в нужное место dataGridInfo.Rows[currentRow].Cells[dataGridInfo.ColumnCount - 1] = comboBox; currentRow++; } } catch (Exception err) { Console.Error.Write(err.Message); MessageBox.Show("Невозможно получить данные о работниках.\nПри выполнении поиска проверьте результаты"); } }