简体   繁体   中英

display single column in list view with two groups

i have customer table have columns with

                                      customer id
                                     customer name 

I have another table called address addressid addresstext

now i want to display the customer name and addresstext like this

                    customers
                    -----------
                    customer name 1
                    customer name 2
                    customer name 3

                    addresses 
                    -----------
                    addresstext 1
                    addresstext 2
                    addresstext 3

like this in list view only single column above figure 在此处输入图片说明

would any one pls help on this..

I am using c# in winforms applications

Many Thanks For all your support and i have solved my problem ........like this

    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 });

您需要在地址表上创建一个指向客户ID的外键。

If you are asking about how to populate the list view with the data from the sql table then have a look at

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/2725cfac-76a0-42f3-90b2-93c6ab96d901/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM