我有一个附加到 C# 项目的数据库,其中包含 3 个表 Company、Product 和 Inventory。Inventory 列出 CompanyID、ProductID 和 Quantity。Combobox1 列出了所有的 companyID。当您选择一个时,我希望 listview1 仅显示 Inventory 中具有该 CompanyID 的行。
//binding DB to memorycopy
this.DBContext = new DBEntities();
listView1.ItemsSource = this.SupPartContext.SPs;
GridViewColumn companyIDColumn = new GridViewColumn();
sNumColumn.Width = 90;
sNumColumn.Header = "companyID";
sNumColumn.DisplayMemberBinding = new Binding("COMPANYID");
GridViewColumn ProductIDColumn = new GridViewColumn();
pNumColumn.Width = 90;
pNumColumn.Header = "ProductID";
pNumColumn.DisplayMemberBinding = new Binding("PRODUCTID");
GridViewColumn quantityColumn = new GridViewColumn();
qtyColumn.Width = 90;
qtyColumn.Header = "quantity";
qtyColumn.DisplayMemberBinding = new Binding("QUANTITY");
GridView newGridview = new GridView();
newGridview.Columns.Add(companyIDColumn);
newGridview.Columns.Add(productIDColumn);
newGridview.Columns.Add(quantityColumn);
listView1.View = newGridview;
任何帮助,即使是正确方向的一点,将不胜感激。感谢您的时间。