I have a frmChoseArticle with a listview. I fill the listview programatically and then check if the items in it are one or more. When the listbox items are more than one I simply activate the right item. When the item is only one I would like that the program automatically selects the first item and show in a message the first two subitems. the code that i pasted here works good when the items are more than one. It doesn't work as expected with a single listview item. i suppose that the way I call the itemactivate event is not ok and especially the parameters "sender" and "e". in the load event the sender is the form itself - frmChooseArticle but in the itemactivate event the sender is something else.
How can i call the listview itemactivate event from the load event of the same form?
How can i call the listview itemactivate event from the load event of the same form?
Public Class frmChoseArticle
Private Sub frmChoseArticle_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If lvwChooseArticle.Items.Count = 1 Then
Call lvwChooseArticle_ItemActivate(sender, e)
End If
End Sub
Private Sub lvwChooseArticle_ItemActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvwChooseArticle.ItemActivate
'populate textboxes with data from the selected row
msgbox(lvwChooseArticle.FocusedItem.SubItems(0).Text & ", " & lvwChooseArticle.FocusedItem.SubItems(1).Text)
End Sub
End Class