Results 1 to 40 of 60

Thread: List View Control

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: List View Control

    Quote Originally Posted by yesfriends
    try this..
    This is also not working. But there is no error also. Simply the listview is empty.

  2. #2
    Junior Member
    Join Date
    Dec 2005
    Posts
    18

    Re: List View Control

    hi create one command button name cmdLoadListView...at onclick event of this command button write below code..
    VB Code:
    1. Dim sSQL As String
    2. Dim lvwItem As ListItem
    3. Set rs = New ADODB.Recordset
    4. sSQL = "SELECT [NAME] FROM TBL1 "
    5. rs.Open sSQL, db
    6. Do Until rs.EOF
    7.     Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
    8.     rs.MoveNext
    9. Loop
    10. rs.Close
    11. Set rs = Nothing

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: List View Control

    Quote Originally Posted by yesfriends
    hi create one command button name cmdLoadListView...at onclick event of this command button write below code..
    VB Code:
    1. Dim sSQL As String
    2. Dim lvwItem As ListItem
    3. Set rs = New ADODB.Recordset
    4. sSQL = "SELECT [NAME] FROM TBL1 "
    5. rs.Open sSQL, db
    6. Do Until rs.EOF
    7.     Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
    8.     rs.MoveNext
    9. Loop
    10. rs.Close
    11. Set rs = Nothing
    Yeah, it is working fine. But please let me know why can't we view the contents without using the commond button (like datagrid)?

    How can I view it in a lvwReport view. I have modified LISTVIEW property to 3 lvwReoprt. But now I can not view any data?

    Please help.

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: List View Control

    Fine remove the command button but it should still work. What i wrote means that it will load the listview no matter what and it will also do it if you press the button, but you can remove the button and it should work
    Last edited by Andrew G; Dec 21st, 2005 at 06:31 AM.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: List View Control

    [/QUOTE]
    then it runs when you open the form and when you click on the command button[/QUOTE]

    I dont want to use commond button to view the listview. When I open the project it should show automatically all the data in a ListView (lvwReport view). Is it possible?

  6. #6
    Junior Member
    Join Date
    Dec 2005
    Posts
    18

    Re: List View Control

    u write this code with form onload event....and when ur form will load then it automatically populate ur list view..
    VB Code:
    1. Dim sSQL As String
    2. Dim lvwItem As ListItem
    3. Set rs = New ADODB.Recordset
    4. sSQL = "SELECT [NAME] FROM TBL1 "
    5. rs.Open sSQL, db
    6. Do Until rs.EOF
    7.     Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
    8.     rs.MoveNext
    9. Loop
    10. rs.Close
    11. Set rs = Nothing

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: List View Control

    When I add the code to Form Load, It shows nothing. The following is the code:

    Private Sub Form_Load()
    Call data_connect
    rs.Open "Select * from TBL1", db
    Set DataGrid1.DataSource = rs
    show_rec

    Dim sSQL As String
    Dim lvwItem As ListItem
    Set rs = New ADODB.Recordset
    sSQL = "SELECT [NAME] FROM TBL1 "
    rs.Open sSQL, db
    Do Until rs.EOF
    Set lvwItem = ListView1.ListItems.Add(, , rs.Fields.Item("Name").Value)
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing

    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