private void buttonApply_Click(object sender, EventArgs e) { var combobxes = tableLayoutPanel.Controls .Cast <Control>() .Where(x => x is ComboBox) .Select(x => (ComboBox)x) .ToList(); if (combobxes.Count > 0) { combobxes.ForEach(x => _tables.Add((ITableManager)x.SelectedItem)); _tables = _tables.Distinct(new TableServiceComparer()).ToList(); _tables.RemoveAll(x => x.Table.Name == _tableService.Table.Name); try { Data = _tableService.Union(_tables.Select(x => x.Table).ToArray()); IsSet = true; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }