A few of my names are different than yours, but I can't find the problem. My selected choice will not highlight. The SessionIndex is correct based on my MessageBox and by checking while debugging. My code is the same as your book code (with a few name variations). Your code hightlights properly, but mine does not
. Since the SessionIndex is set correctly when the form loads it seems the the problem should be in this code, but I cannot find it.
Public Class SessionForm
' Public variables to communicate with the main form.
Public SessionIndex As Integer
Public SessionTitle As String
' Initialize the selection
Private Sub SessionForm_Load() Handles MyBase.Load
MessageBox.Show("SessionIndex is " & SessionIndex)
' Ensure that the selection is visible.
Private Sub btnOk_Click(sender As System.Object, e As System.EventArgs) Handles btnOk.Click
' Save the user's selection.
SessionIndex = lvwSession.SelectedIndices(0)
SessionTitle = lvwSession.SelectedItems(0).Text