private void LoadProducts() { string token = Session.Token; var findProducts = VirtualFairIntegration.FindAllProducts(token); cmbProducts.DataSource = findProducts.products; cmbProducts.DisplayMember = "name"; cmbProducts.ValueMember = "id"; cmbProducts.DropDownStyle = ComboBoxStyle.DropDownList; }
public NewPurchaseRequestExternal() { InitializeComponent(); dgvProducts1.AutoGenerateColumns = false; string[] arrayString = new string[] { "idProduct", "nameProduct", "weight", "remark", "requiresRefrigeration" }; foreach (var item in arrayString) { DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn(); dataGrid.DataPropertyName = item; if (item == "idProduct") { dataGrid.HeaderText = "Id Product"; } else if (item == "nameProduct") { dataGrid.HeaderText = "Nombre Producto"; } else if (item == "weight") { dataGrid.HeaderText = "Peso Kg"; } else if (item == "remark") { dataGrid.HeaderText = "Comentario"; } else if (item == "requiresRefrigeration") { dataGrid.HeaderText = "Requiere Refrigeración"; } dataGrid.Name = item; dgvProducts1.Columns.Add(dataGrid); } DataGridViewButtonColumn deleteButton = new DataGridViewButtonColumn(); deleteButton.FlatStyle = FlatStyle.Popup; deleteButton.HeaderText = "Eliminar"; deleteButton.Name = "Eliminar"; deleteButton.UseColumnTextForButtonValue = true; deleteButton.Text = "Eliminar"; deleteButton.Width = 60; if (dgvProducts1.Columns.Contains(deleteButton.Name = "Eliminar")) { } else { dgvProducts1.Columns.Add(deleteButton); } var filenamesList = new BindingList <AddProducts>(items); dgvProducts1.DataSource = filenamesList; string token = Session.Token; var findProducts = VirtualFairIntegration.FindAllProducts(token); cmbProducts.DataSource = findProducts.products; cmbProducts.DisplayMember = "name"; cmbProducts.ValueMember = "id"; cmbProducts.DropDownStyle = ComboBoxStyle.DropDownList; }