i have create a checkbox in listview...so i wanna know how to check it and export only check item to crystal report so i can print item that i have check... please anyone help me..

See if this helps for locating only the checked items in a ListView.

For Each itm As ListViewItem In ListView1.CheckedItems
            MsgBox(itm.Text)
        Next

Or you could use the _ItemChecked event to locate the currently checked item.

Private Sub ListView1_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles ListView1.ItemChecked
        If e.Item.Checked Then
            MsgBox(e.Item.Text)
        End If
    End Sub

i have this code on my form to update data..if i put yr code..i will get error if i check..


Private Sub ListView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView.Click
frUpdate = True

update_table.produk_baru.Text = ListView.SelectedItems(0).SubItems(0).Text
update_table.model_baru.Text = ListView.SelectedItems(0).SubItems(1).Text
update_table.kuantiti_baru.Text = ListView.SelectedItems(0).SubItems(2).Text
update_table.tarikh_baru.Value = ListView.SelectedItems(0).SubItems(3).Text
update_table.stockout.Text = ListView.SelectedItems(0).SubItems(4).Text
update_table.kirajew.Text = ListView.SelectedItems(0).SubItems(5).Text
update_table.dateout.Value = ListView.SelectedItems(0).SubItems(6).Text
update_table.id.Text = ListView.SelectedItems(0).SubItems(7).Text

End Sub

>>i have this code on my form to update data..if i put yr code..i will get error if i check..
Nice to know.
.Mind sharing what error occurs and possibly which line the error occurs on?

when i run system...if check item,i get this error

InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index

checkbox in column1..

if i click on other column item like column2 and after that i click checkbox,i can check and uncheck item without problem..

>>InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index
It is because you probably do not have an item selected since your code checks for ListView.SelectedItems(0).SubItems(0).Text .

Private Sub ListView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView.Click
        If Not ListView.SelectedItems.Count = 0 Then
            '// code here since an item is selected.
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.