我希望组合框项目显示在列表视图中 [英] I want Combo box items to display in a listview
本文介绍了我希望组合框项目显示在列表视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够选择一个组合框项目,并选择该项目,它需要在列表视图中显示所选项目,我需要使用LINQ。我有一个产品表,产品名称显示在组合框中,整个表显示在列表视图中。如果有关于此的教程或文章,我将非常感谢链接,谢谢。
解决方案
示例查询可能如下所示:
< pre lang =c#> string pname = ComboBox1.SelectedItem.ToString();
ListView1.ItemsSource = ProductsDataContext.Where(p => p.ProductName == pname);
CP'文章:
简单使用LINQ-SQL在WPF中绑定到数据库的演示 [ ^ ]
WPF中的数据可视化,LINQ to SQL和数据绑定 [ ^ ]
I want to be able to select a combo box item and by selecting that item it needs to display that selected item in a listview and I need to use LINQ. I have a product table where the product name is shown in the combo box and the entire table in the listview. if there is a tutorial or an article on this I would appreciate a link thank you.
解决方案
Sample query could look like:
string pname = ComboBox1.SelectedItem.ToString(); ListView1.ItemsSource = ProductsDataContext.Where(p=>p.ProductName == pname);
CP' articles:
Simple Demo of Binding to a Database in WPF using LINQ-SQL[^]
Data Visualization in WPF with LINQ to SQL and Data Binding[^]
这篇关于我希望组合框项目显示在列表视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文