0

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim i As Integer
Dim lvitem As ListViewItem
For i = 1 To 5
lvitem = ListView1.Items.Add("1")
lvitem.SubItems.Add("sonia")

Next
End Sub

Above code add the five items in a listview with checboxes before each item.
When we run the form,all Checkboxes are unchecked.I want that by default all checkboxes are checked...
Ur help will be highly appreciated!!!!!!

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by ruchika beddy
1
Private Sub ListView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Dim i As Integer
        Dim lvitem As ListViewItem
        For i = 1 To 5
            lvitem = ListView1.Items.Add("1")
            lvitem.SubItems.Add("sonia")
            lvitem.Checked = True
        Next 
End Sub
Votes + Comments
worked
0

hey,thx . I want to save the checked items into the textfile--
But with my code all the items are written in textFile.I m posting my code as follows-
Plz go thru it.

On Button2 click,I want that items that are checked are saved into the textfile.
Call SaveTextToFile is the procedure that saves the records into the textfile. I know that procedure dats y not pasting.
Plz just tell me that to procedure SaceTextToFile only that records are passed dat are checked.


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim checkedItems As ListView.CheckedListViewItemCollection = ListView1.CheckedItems
Dim lvitem As ListViewItem
Dim lcount As Integer


For Each lvitem In checkedItems

For lcount = 0 To ListView1.Items.Count - 1
Call SaveTextToFile(ListView1.Items(lcount).SubItems(0).Text, ListView1.Items(lcount).SubItems(1).Text)
Next
Next

End Sub

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.