Results 1 to 15 of 15

Thread: Listview Error

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy Listview Error

    Hi

    I see example below:
    Code:
        Dim itmX As ListItem ' Create a variable to add ListItem objects.
        Dim clmX As ColumnHeader ' Create an object variable for the ColumnHeader object.
       ' Add ColumnHeaders.
        Set clmX = ListView1.ColumnHeaders.Add(, , "Column 1", ListView1.Width / 3)
        Set clmX = ListView1.ColumnHeaders.Add(, , "Column 2", ListView1.Width / 3)
        Set clmX = ListView1.ColumnHeaders.Add(, , "Column 3", ListView1.Width / 3)
        
        ListView1.BorderStyle = ccFixedSingle ' Set BorderStyle property.
        ListView1.View = lvwReport ' Set View property to Report.
        
        ' Add a main item
        Set itmX = ListView1.ListItems.Add(, , "First value")
        ' Add two subitems for that item
        itmX.SubItems(1) = "First value subitem 1"
        itmX.SubItems(2) = "First value subitem 2"
    But when I put in my code
    Code:
        Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.Fields("TB02_PK"))
              itmX.SubItems(0) = "xxxx"
    It return me error Invalid property value

  2. #2

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Listview Error

    shouldn't it be:
    VB Code:
    1. itmX.SubItems(1) = "xxxx"
    Edit: Dang! too slow.

  4. #4

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy Re: Listview Error

    I tried , but do not work
    Code:
    Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.Fields("TB02_PK"))
    itmX.SubItems(1) = Trim(Ret_Sql("TB02_NOME").Value)
    Invalid property value

  5. #5

  6. #6

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Listview Error

    Is a Recordset

  7. #7

  8. #8

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Listview Error

    When I put a constant String , eg "XXXX", too do not work

  9. #9
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Listview Error

    Stupid question but you are creating the coulmns by running this code before the statement that is giving you the error?

    VB Code:
    1. ' Add ColumnHeaders.
    2.     Set clmX = ListView1.ColumnHeaders.Add(, , "Column 1", ListView1.Width / 3)
    3.     Set clmX = ListView1.ColumnHeaders.Add(, , "Column 2", ListView1.Width / 3)
    4.     Set clmX = ListView1.ColumnHeaders.Add(, , "Column 3", ListView1.Width / 3)


    Also is the listview in Report View?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  10. #10

  11. #11

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy Re: Listview Error

    Sorry

    Thank you

  12. #12

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Red face Re: Listview Error

    I am using as
    Code:
    Private Sub Form_Load()
       ...
    ....
        Define_Listview
    
    End Sub
    Private Sub Define_Listview()
       Dim clmX As ColumnHeader
        Dim i As Integer
    
     ' With lvw_profissional
      Set clmX = lvw_profissional.ColumnHeaders.Add(, , "Código")
      Set clmX = lvw_profissional.ColumnHeaders.Add(, , "Profissional")
      
      lvw_profissional.BorderStyle = ccFixedSingle ' Set BorderStyle property.
      lvw_profissional.View = lvwReport
      
      
     ' Set itmX = lvw_profissional.ListItems.Add(, , 2)
     ' itmX.SubItems(1) = "xxxx"
         
      
    End Sub
    
    Private Sub Carregar_Funcionarios()
    
       Dim LSql As String
       Dim lInd As Integer
      Dim itmX As ListItem
    
       On Error GoTo CarregarFLUXOErro
       Screen.MousePointer = vbHourglass
    
        
        
        
        
       'lst_profissional.
       cmb_profissional.Clear
    
       LSql = "SELECT TB02_PK, "
       LSql = LSql & " TB02_NOME  "
       LSql = LSql & " FROM    TB02 "
       LSql = LSql & " ORDER BY 2 "
       Call Executar_Sql(LSql, Ret_Sql)
    
       'cmb_Grupo.AddItem "{Nenhum}"
       ' cmb_Grupo.ItemData(cmb_Grupo.NewIndex) = 0
    
       If Not (Ret_Sql Is Nothing) Then
          While Not Ret_Sql.EOF
          
               
               Set itmX = lvw_profissional.ListItems.Add(, ,Ret_Sql ("TB02_PK").Value)
        i     tmX.SubItems(1) = TrimRet_Sql ("TB02_NOME").Value)
            
             cmb_profissional.AddItem Trim(Ret_Sql("TB02_NOME").Value)
             cmb_profissional.ItemData(cmb_profissional.NewIndex) = Ret_Sql.Fields("TB02_PK")
             Ret_Sql.MoveNext
          Wend
          Ret_Sql.Close
       End If
    
       Screen.MousePointer = vbNormal
       Exit Sub
    
    CarregarFLUXOErro:
       Screen.MousePointer = vbNormal
       'Call Tratar_Erro
    End Sub
    When I put constaants , too return me error

    Thank you in advance

  13. #13
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Listview Error

    I'm not sure what you mean but highlighted text (code) makes no sense - try replacing with the following:
    VB Code:
    1. Set itmX = lvw_profissional.ListItems.Add(, , Ret_Sql.[B]Fields[/B]("TB02_PK").Value)
    2.     tmX.SubItems(1) = Trim(Ret_Sql.[B]Fields[/B]("TB02_NOME").Value)

  14. #14

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Listview Error

    Hi

    My work fine as:

    Code:
    Private Sub Carrega_Listview(Prs As ADODB.Recordset)
      Dim itmX As ListItem
      
      
      Set itmX = lvw_profissional.ListItems.Add(, , Prs("TB02_PK").Value)
      'itmX.SubItems(1) = Trim(Prs("TB02_NOME").Value)
      itmX.ListSubItems.Add , , Prs("TB02_NOME").Value
    End Sub
    Thank you

  15. #15

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