Results 1 to 7 of 7

Thread: ListView control

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    ListView control

    When I coding the windows application, I can add the values into listview, same as
    ListView1.items.Add("test")

    but it can not work in PPC application, how can I code it in cf 1.1 ?

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ListView control

    With the ListView in order to add items to it you need to create a listviewitem then you add the listviewitem to the listview

    EG:
    Dim lvi As New ListViewItem("test")
    listview1.items.add(lvi)
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: ListView control

    Thanks...

    I know the ListViewItem support array input, why the program only show "go"?

    Dim d(3) As String
    d(0) = "go"
    d(1) = "to"
    d(2) = "you"
    Dim lvi As New ListViewItem(d)
    ListView1.Items.Add(lvi)

  4. #4
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ListView control

    You need to add subitems to the listviewitem

    here is an example

    l_dr is just a datareader im using

    Dim l_lvi As New ListViewItem(l_dr.Item("ID").ToString)
    l_lvi.SubItems.Add(l_dr.Item("RouteNo").ToString)
    l_lvi.SubItems.Add(l_dr.Item("CompCode").ToString)
    l_lvi.SubItems.Add(Date.Parse(l_dr.Item("DateInit")).ToShortDateString)
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: ListView control

    Thanks, It work...

    and do you know how to control the listview items.
    such as when I press the listview item, I call the event..

  6. #6
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: ListView control

    you will do that in the listview click event or else even the itemactivate event
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: ListView control

    Quote Originally Posted by Strider
    you will do that in the listview click event or else even the itemactivate event

    Thanks,
    but when I use Itemactivate event, how can I call I selected item value?

    Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate
    MsgBox(ListView1.Text)


    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width