我的客户表中有
列 customer id
customer name
我有另一个名为address的表 addressid addresstext
现在我想显示像这样的客户名称和地址文本
customers
-----------
customer name 1
customer name 2
customer name 3
addresses
-----------
addresstext 1
addresstext 2
addresstext 3
这样在列表视图中只有图
上方的单个列任何人都可以帮忙...
我在winforms应用程序中使用c#
答案 0 :(得分:5)
非常感谢您的支持,我已经解决了我的问题........像这样
lstviewcategories.View = View.Details;
lstviewcategories.Columns.Add(new ColumnHeader() { Width = lstviewcategories.Width - 20 });
lstviewcategories.HeaderStyle = ColumnHeaderStyle.None;
lstviewcategories.Sorting = SortOrder.Ascending;
lstviewcategories.Dock = DockStyle.None;
ListViewGroup categorygroup = new ListViewGroup("Category Types",HorizontalAlignment.Center);
lstviewcategories.Groups.Add(categorygroup);
var categorytypes = (from categories in abc.categories
select categories.category_Name).ToList();
lstviewcategories.Items.Add(new ListViewItem() { Text = "ALL", Group = categorygroup });
foreach (string item in categorytypes)
{
lstviewcategories.Items.Add(new ListViewItem() { Text = item.ToString(), Group = categorygroup });
}
ListViewGroup pricerangegroup = new ListViewGroup("Price Ranges", HorizontalAlignment.Center);
lstviewcategories.Groups.Add(pricerangegroup);
lstviewcategories.Items.Add(new ListViewItem() { Text = "ALL", Group = pricerangegroup });
lstviewcategories.Items.Add(new ListViewItem() { Text = "0-500", Group = pricerangegroup });
lstviewcategories.Items.Add(new ListViewItem() { Text = "500-1000", Group = pricerangegroup });
lstviewcategories.Items.Add(new ListViewItem() { Text = "1000+", Group = pricerangegroup });
答案 1 :(得分:0)
您需要在地址表上创建一个指向客户ID的外键。
答案 2 :(得分:0)
如果您询问如何使用sql表中的数据填充列表视图,那么请查看