private void ShowProductName() { var rowView = recipeBindingSource.Current as DataRowView; if (rowView == null) { return; } var row = rowView.Row as MyRecipeRow; CNameIDForComboBox product = m_ProductList[0]; // 第一個放的是ID=0 Name "" if (!row.IsFinalProductIDNull()) { int id = row.FinalProductID; foreach (CNameIDForComboBox p in m_ProductList) { if (id == p.ID) { product = p; break; } } } this.finalProductIDComboBox.SelectedItem = product; }
private void IngredientBindingSource_CurrentChanged(object sender, EventArgs e) { if (m_VendorList != null && m_VendorList.Count > 0) { DataRowView rowView = IngredientBindingSource.Current as DataRowView; var row = rowView.Row as MyIngredientRow; CNameIDForComboBox vendor = m_VendorList[0]; // 第一個放的是ID=0 Name "" if (!row.IsVendorIDNull()) { int id = row.VendorID; foreach (CNameIDForComboBox v in m_VendorList) { if (id == v.ID) { vendor = v; break; } } } vendorIDComboBox.SelectedItem = vendor; } CalcCostPerGram(); // 手動載入Photo if (!photoPictureBox.Visible) { return; } TryShowPhoto(CurrentPhotoID(), (int)PhotoTableID.Ingredient, "食材", 240, 240); }
private void vendorIDComboBox_SelectedIndexChanged(object sender, EventArgs e) { ComboBox box = sender as ComboBox; var rowView = IngredientBindingSource.Current as DataRowView; var row = rowView.Row as MyIngredientRow; object obj = box.SelectedItem; if (obj != null && obj != DBNull.Value) { CNameIDForComboBox nameId = obj as CNameIDForComboBox; row.VendorID = nameId.ID; } }