private void FormCreateOrder_Load(object sender, EventArgs e) { try { List <BuyerViewModel> listC = serviceC.GetList(); if (listC != null) { comboBoxClient.DisplayMember = "BuyerFIO"; comboBoxClient.ValueMember = "Id"; comboBoxClient.DataSource = listC; comboBoxClient.SelectedItem = null; } List <GBIpieceOfArtViewModel> listP = serviceP.GetList(); if (listP != null) { comboBoxProduct.DisplayMember = "GBIpieceOfArtName"; comboBoxProduct.ValueMember = "Id"; comboBoxProduct.DataSource = listP; comboBoxProduct.SelectedItem = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadData() { try { List <GBIpieceOfArtViewModel> 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); } }