Display a single column as a list with two groups

I have a customer table with columns with

                                      customer id
                                     customer name 

I have another table called AddressID addresstext

now i want to display client name and addresstext like this

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

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

as in the list in the list there is only one column above the figure enter image description here

will anyone help with this.

I use C # in winforms applications

+5
source share
3 answers

Thank you very much for your support, and I 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 });
+5
source

You need to create a foreign key in your address table by pointing to the client ID.

0

If you are asking how to populate a list view with data from sql table, look

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

0
source

All Articles