Todd MacPherson
asked on
See bottom item of listview automatically as new items are added
Hi
I have a problem I do not know how to solve. After a user adds enough items to a listview causing the vertical scrollbar to appear, the bottom (or most recently added item) is not displayed unless the user scrolls down manually. Is there anyway to make it display the bottom item automatically after it is added to the listview?
Thanks
PBLack
- PS I have another question of a similar nature involving promoting and/or demoting items in a listview
see https://www.experts-exchange.com/questions/22479630/Listview-Items-and-scrolling-issues-when-promoting-and-demoting-items.html
Dim Xsub As String = (lstMenu.Items.Count + 1).ToString
Dim lstAttItem As ListViewItem = New ListViewItem(Xsub)
Dim lvDup As ListViewItem
Dim blnDuplicate As Boolean
For Each lvDup In lstMenu.Items
If UCase(Trim(lvDup.SubItems( 1).Text)) = UCase(Trim(txtName.Text)) OrElse (UCase(txtCode1.Text.Trim) = Trim(lvDup.SubItems(2).Tex t) And UCase(txtCode1.Text.Trim) <> "0") Then 'OrElse UCase(txtCode2.Text.Trim) = lvDup.SubItems(2).Text Then
Beep()
MsgBox("Duplicate entries are not permitted in Value or Code 1 columns. Please fix.", MsgBoxStyle.Information)
txtName.Focus()
blnDuplicate = True
Exit For
End If
Next
If Not blnDuplicate Then
Beep()
lstMenu.Items.Add(lstAttIt em)
'lstAttItem.SubItems.Add(s ub1Pad)
'lstAttItem.SubItems.Add(s ub2Pad)
'lstAttItem.SubItems.Add(s ub3Pad)
lstAttItem.SubItems.Add(Tr im(txtName .Text))
lstAttItem.SubItems.Add(Tr im(txtCode 1.Text))
lstAttItem.SubItems.Add(Tr im(txtCode 2.Text))
End If
I have a problem I do not know how to solve. After a user adds enough items to a listview causing the vertical scrollbar to appear, the bottom (or most recently added item) is not displayed unless the user scrolls down manually. Is there anyway to make it display the bottom item automatically after it is added to the listview?
Thanks
PBLack
- PS I have another question of a similar nature involving promoting and/or demoting items in a listview
see https://www.experts-exchange.com/questions/22479630/Listview-Items-and-scrolling-issues-when-promoting-and-demoting-items.html
Dim Xsub As String = (lstMenu.Items.Count + 1).ToString
Dim lstAttItem As ListViewItem = New ListViewItem(Xsub)
Dim lvDup As ListViewItem
Dim blnDuplicate As Boolean
For Each lvDup In lstMenu.Items
If UCase(Trim(lvDup.SubItems(
Beep()
MsgBox("Duplicate entries are not permitted in Value or Code 1 columns. Please fix.", MsgBoxStyle.Information)
txtName.Focus()
blnDuplicate = True
Exit For
End If
Next
If Not blnDuplicate Then
Beep()
lstMenu.Items.Add(lstAttIt
'lstAttItem.SubItems.Add(s
'lstAttItem.SubItems.Add(s
'lstAttItem.SubItems.Add(s
lstAttItem.SubItems.Add(Tr
lstAttItem.SubItems.Add(Tr
lstAttItem.SubItems.Add(Tr
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points. You really only need to call the method on the single item - the last one added, or the moved one that has been reinserted - rather than on all of them.
Roger
Roger
ASKER
how would I do that? I am a relative newbie to this
PBLack
PBLack
ASKER
I switched it to this:
Dim i As Integer
i = lstMenu.Items.Count - 1
lstMenu.Items(i).EnsureVis ible(
Is that better?
PBLack
Dim i As Integer
i = lstMenu.Items.Count - 1
lstMenu.Items(i).EnsureVis
Is that better?
PBLack
ASKER
oops
Dim i As Integer
i = lstMenu.Items.Count - 1
lstMenu.Items(i).EnsureVis ible()
Missed the closing bracket
Dim i As Integer
i = lstMenu.Items.Count - 1
lstMenu.Items(i).EnsureVis
Missed the closing bracket
The last one's fine
Roger
Roger
ASKER
thanks for all of the help
PBLack
PBLack
ASKER
Dim i As Integer
For i = 0 To lstMenu.Items.Count - 1
lstMenu.Items(i).EnsureVis
Next
to routine
Thanks