Listview columns

dashley

Well-known member
Joined
May 27, 2005
Messages
59
Location
Tennessee
Programming Experience
10+
Hi. I'm used to working with listviews that have checkboxes.
I have the one below and I figured I just false the checkbox and have 2 col's of data displayed. Well I guess I figured wong. I can't seem to figure out how to make 2 simple col's display. I get the headers but nothing in the 1st col.
I want the link to show in col 1 and the description (desc) to display in col 2.

Thanks

dash


VB.NET:
Expand Collapse Copy
        Dim cmdcodes As New SqlCeCommand
        cmdcodes.CommandText = ("Select link, desc from spt_codes order by desc")
        Dim itemis As String = Nothing

        Dim conn As New SqlCeConnection(connstr)
        cmdcodes.Connection = conn
        conn.Open()

        Dim drcodes As SqlCeDataReader = cmdcodes.ExecuteReader

        Me.ListView1.Columns.Clear()
        Me.ListView1.Items.Clear()
        ListView1.CheckBoxes = False
        ListView1.Activation = ItemActivation.TwoClick
        ListView1.Columns.Add("Ck", 25, HorizontalAlignment.Left)
        ListView1.Columns.Add("Items", 400, HorizontalAlignment.Left)

        While drcodes.Read

            Dim lvi As New Windows.Forms.ListViewItem
            itemis = drcodes(1)
            lvi.SubItems.Add(itemis)
            Me.ListView1.Items.Add(lvi)

        End While

        ListView1.View = View.Details
 
Got it

VB.NET:
Expand Collapse Copy
Dim drcodes As SqlCeDataReader = cmdcodes.ExecuteReader
        Me.ListView1.Clear()
        ListView1.Activation = ItemActivation.OneClick
        ListView1.Columns.Add("Link", 50, HorizontalAlignment.Left)
        ListView1.Columns.Add("Description", 200, HorizontalAlignment.Left)

        Dim lvi As Windows.Forms.ListViewItem
        While drcodes.Read

                      lvi = New Windows.Forms.ListViewItem(drcodes("link").ToString)
            lvi.SubItems.Add(drcodes("description").ToString)
            Me.ListView1.Items.Add(lvi)

        End While
 
Back
Top