select new added ListViewItem
I have Main and Detail forms.开发者_JAVA百科 The Main form has ListView1. I would like to select new added ListViewItem in ListView1 when user click Save button in Detail form. I have problem only when I'm adding new item. When I modify and save existing item according item is selected after save command. I will appreciate for sample.
This code seems to work for me if I add it to the Save button handler in the second form:
With Form1.ListView1
.Items.Add("item from form2")
For i As Integer = 1 To .Items.Count
.Items(i - 1).Selected = (i = .Items.Count)
Next
End With
精彩评论