Results 1 to 9 of 9

Thread: list view problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    list view problem

    in my list view i have a checkbox how can i put the one that the user check in the list view to the database

    VB Code:
    1. If LV1.ListItems.Count - 1 > -1 Then
    2.                
    3.                 ItemCount = -1
    4.                 For Each ls In LV1.ListItems
    5.                     If ls.Checked = True Then
    6.                         ItemCount = ItemCount + 1
    7.                     End If
    8.                 Next
    9.                
    10.                 ReDim AccessTitle(ItemCount)
    11.                
    12.                i = 0
    13.                For Each ls In LV1.ListItems
    14.                
    15.                     If ls.Checked = True Then
    16.                    
    17.                         AccessTitle(i) = ls.Text
    18.                         i = i + 1
    19.                     End If
    20.                 Next
    21.     End If
    22.    
    23. End Sub
    24.  
    25. 'Private Sub cmbType_Click()
    26. '
    27. '    If cmbType.Text = sAdministratortitle Then
    28. '
    29. '        For Each ls In LV1.ListItems
    30. '            If ls.SubItems(1) = sAdministratortitle Then
    31. '                ls.Checked = True
    32. '            End If
    33. '        Next
    34. '
    35. '
    36. '    ElseIf cmbType.Text = sEncoderTitle Then
    37. '
    38. '        For Each ls In LV1.ListItems
    39. '            If ls.SubItems(1) = sAdministratortitle Then
    40. '                ls.Checked = False
    41. '            End If
    42. '        Next
    43. '
    44. '    End If

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: list view problem

    eh what do you mean by database? txt file or something else?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    Re: list view problem

    a text

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: list view problem

    hmm do you have more than one column header?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    Re: list view problem

    no i only have 1 column

  6. #6
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: list view problem

    kk ill figure something out for you one moment

  7. #7
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: list view problem

    hmm do you want it to be removed once you send it to the txt file?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    Re: list view problem

    no i just want it to put in the database

  9. #9
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: list view problem

    VB Code:
    1. Private Sub Command2_Click()
    2. On Error Resume Next
    3. Open App.Path & "\lst.txt" For Output As #1
    4. Dim it As ListItem
    5. For Each it In ListView1.ListItems
    6. If it.Checked = True Then
    7. Print #1, it
    8. End If
    9. Next
    10. End Sub
    this worked for me it send all the checked items to the lst.txt file

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