Private Sub lvUnavailableProducts_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvUnavailableProducts.SelectedIndexChanged
Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM Product_Suppliers WHERE ProductCode = '" & lvUnavailableProducts.SelectedItems(0).SubItems(0).Text & "'", conn)
conn.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
If sdr.Read = True Then
Fill("SELECT DISTINCT SupplierCode, SupplierName FROM Product_Suppliers WHERE ProductCode ='" & lvUnavailableProducts.SelectedItems(0).SubItems(0).Text & "'", lvProductSupplier)
conn.Close()
Else
MsgBox("No added Supplier Yet, Please add a supplier")
lvProductSupplier.Items.Clear()
conn.Close()
End If
End Sub
我在更改LvUnavailableProducts上的选定数据时遇到错误
请帮忙谢谢:D
答案 0 :(得分:0)
尝试将.SelectedItems(0)
更改为.FocusedItem
lvUnavailableProducts.FocusedItem.SubItems(0).Text