private void FormPutToFridge_Load(object sender, EventArgs e) { try { List <ProductViewModel> listC = serviceC.GetList(); if (listC != null) { comboBoxProduct.DisplayMember = "ProductName"; comboBoxProduct.ValueMember = "Id"; comboBoxProduct.DataSource = listC; comboBoxProduct.SelectedItem = null; } List <FridgeViewModel> listS = serviceS.GetList(); if (listS != null) { comboBoxFridge.DisplayMember = "FridgeName"; comboBoxFridge.ValueMember = "Id"; comboBoxFridge.DataSource = listS; comboBoxFridge.SelectedItem = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadData() { try { List <FridgeViewModel> list = service.GetList(); if (list != null) { dataGridView.DataSource = list; dataGridView.Columns[0].Visible = false; dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }