Click here to Skip to main content
14,870,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am using VB.NET and WPF.

I need to bind multiple columns in WPF listview.

In XAML, I have created a listview control and created two column headers in it.

In VB code, I have binded data to created columns:

listview.items.add
listview.subitems.add


but not able to bind datas to multiple columns of Listview

Kindly help on this issue

Thanks in advance.

Naveen.... :confused:
Posted
Updated 6-Mar-10 23:11pm
v2

WPF's ListView doesn't have "SubItems" like the Windows Forms ListView does.

do this in yur C# code:

listView.ItemsSource = myCollection;


and something like this in your XAML

XML
<ListView Margin="6,180,5,5" 
          Name="listView"
          ItemsSource="{Binding}" >
    <ListView.View>
        <GridView>
            <GridViewColumn Width="400" Header="Title"  
                DisplayMemberBinding="{Binding Path=MyProperty}" />
        </GridView>
    </ListView.View>
</ListView>
   
Thanks again Mr.John Simmons

Here iam using vb.net Coding and WPF application

This is how i tried in Windows
VB
con.Open()
       Dim strSQL As String = "Select * from Addressbook"
       Dim cmd As New SqlClient.SqlCommand(strSQL, con)
       Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader()
       Dim j As Integer = 0
       If reader.HasRows Then
           While reader.Read()
               ListViewAddressBook.Items.Add("")
               ListViewAddressBook.Items(j).SubItems.Add(reader(2))
               ListViewAddressBook.Items(j).SubItems.Add(reader(3))
               ListViewAddressBook.Items(j).SubItems.Add(reader(4))
               ListViewAddressBook.Items(j).SubItems.Add(reader(5))
               AddressBookMobileArrayList.Add(ListViewAddressBook.Items(j).SubItems(3).Text)
               j = j + 1
           End While
       End If
       reader.Close()
       con.Close()


BUT WHEN I TRIED THIS IN WPF,its giving error

Kindly guide me Mr.John Simmons

Thanks in advance

Naveen...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900