private void FormOutputElement_Load(object sender, EventArgs e) { try { List <ElementViewModel> list = service.GetList(); if (list != null) { comboBoxComponent.DisplayMember = "ElementName"; comboBoxComponent.ValueMember = "Id"; comboBoxComponent.DataSource = list; comboBoxComponent.SelectedItem = null; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (model != null) { comboBoxComponent.Enabled = false; comboBoxComponent.SelectedValue = model.ElementId; textBoxCount.Text = model.Number.ToString(); } }
public ActionResult AddElement() { var ingredients = new SelectList(ingredientService.GetList(), "Id", "ElementName"); ViewBag.Elements = ingredients; return(View()); }
private void LoadData() { try { List <ElementViewModel> 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); } }
// GET: Elements public ActionResult Index() { return(View(service.GetList())); }