Can't make listview ensurevisible cause scroll to selected row/item

  • Thread starter Thread starter Shady Brady Hat
  • Start date Start date
S

Shady Brady Hat

Guest
Simple routine where the user selects a drive to be used and that drive.name (X:\) is saved in a setting for the next use. On the next use I attempt so select the last used drive.name and cause it to be scrolled into view. I have several other programs and doing similar things with listview and they all are working. I have compared and the code and setup for listview is the same. Looking for any hints. See the code and the setup for the listview below. The proper line in the listview is selected.

With AvailableDrivesListView
.Columns.Clear()
.GridLines = True
.View = View.Details
.Columns.Add("Drive", -2, HorizontalAlignment.Left)
.Columns.Add("Space Available", -2, HorizontalAlignment.Left)
.FullRowSelect = True
.Visible = True
.Enabled = True
.CheckBoxes = False
.Scrollable = True
.AutoArrange = True
.HideSelection = False
.MultiSelect = False
.Sorting = SortOrder.None
.Refresh()
End With



Code doing the selection and ensurevisible. Reversing the order of the two key lines of code make no difference.

If My.Settings.AvailableDrivesListViewText <> "" Then
For i = 0 To AvailableDrivesListView.Items.Count - 1
If AvailableDrivesListView.Items.Item(i).Text = My.Settings.AvailableDrivesListViewText Then
AvailableDrivesListView.EnsureVisible(i)
AvailableDrivesListView.Items.Item(i).Selected = True
Exit For
End If
Next i
End If




Gene

Continue reading...
 
Back
Top