Todd MacPherson
asked on
Listview Items and scrolling issues when promoting and demoting items.
Hi
I have a problem I do not know how to solve. I have a couple of buttons where a user selecets items in a listview and clicks a button causing item to either promote or demote in the listview by one position per click. If the amount of items exceeds the listview height then a vertical scrollbar is present, and herein lies the problem.
If the user, for example, promotes an item near the bottom of the listview, and it moves up far enough the user can no longer see it unless they manually scroll to it. Is there anyway to make sure that the selected item always stays in view no matter how many items are in the listview?
Thanks
PBLack
PS I have a similar question concerning scrolling issues at https://www.experts-exchange.com/questions/22479629/See-bottom-item-of-listview-automatically-as-new-items-are-added.html
========================== ========== ========== =
PROMOTE CODE:
If lstMenu.SelectedIndices.Co unt = 0 Then
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lstMenu.Items(lstMenu.Sele ctedIndice s(0))
Dim inx As Integer
Dim temp As Integer
temp = lstMenu.Items.IndexOf(lvi)
If temp = 0 Then
Beep()
Exit Sub
End If
inx = temp - 1
Dim x As Integer = (lstMenu.SelectedIndices.C ount - 1)
While x >= 0
lstMenu.Items.RemoveAt(lst Menu.Selec tedIndices (x))
System.Math.Max(System.Thr eading.Int erlocked.D ecrement(x ), x + 1)
End While
Beep()
lstMenu.Items.Insert(inx, lvi)
========================== ========== =====
DEMOTE CODE:
If lstMenu.SelectedIndices.Co unt = 0 Then
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lstMenu.Items(lstMenu.Sele ctedIndice s(0))
Dim inx As Integer
Dim temp As Integer
Dim Y As Integer
temp = lstMenu.Items.IndexOf(lvi)
Y = lstMenu.Items.Count
If temp = Y - 1 Then
Beep()
Exit Sub
End If
inx = temp + 1
Dim x As Integer = (lstMenu.SelectedIndices.C ount - 1)
While x >= 0
lstMenu.Items.RemoveAt(lst Menu.Selec tedIndices (x))
System.Math.Max(System.Thr eading.Int erlocked.D ecrement(x ), x + 1)
End While
Beep()
lstMenu.Items.Insert(inx, lvi)
Thanks
PBLack
- PS I have another question of a similar nature involving adding items to a listview
I have a problem I do not know how to solve. I have a couple of buttons where a user selecets items in a listview and clicks a button causing item to either promote or demote in the listview by one position per click. If the amount of items exceeds the listview height then a vertical scrollbar is present, and herein lies the problem.
If the user, for example, promotes an item near the bottom of the listview, and it moves up far enough the user can no longer see it unless they manually scroll to it. Is there anyway to make sure that the selected item always stays in view no matter how many items are in the listview?
Thanks
PBLack
PS I have a similar question concerning scrolling issues at https://www.experts-exchange.com/questions/22479629/See-bottom-item-of-listview-automatically-as-new-items-are-added.html
==========================
PROMOTE CODE:
If lstMenu.SelectedIndices.Co
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lstMenu.Items(lstMenu.Sele
Dim inx As Integer
Dim temp As Integer
temp = lstMenu.Items.IndexOf(lvi)
If temp = 0 Then
Beep()
Exit Sub
End If
inx = temp - 1
Dim x As Integer = (lstMenu.SelectedIndices.C
While x >= 0
lstMenu.Items.RemoveAt(lst
System.Math.Max(System.Thr
End While
Beep()
lstMenu.Items.Insert(inx, lvi)
==========================
DEMOTE CODE:
If lstMenu.SelectedIndices.Co
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lstMenu.Items(lstMenu.Sele
Dim inx As Integer
Dim temp As Integer
Dim Y As Integer
temp = lstMenu.Items.IndexOf(lvi)
Y = lstMenu.Items.Count
If temp = Y - 1 Then
Beep()
Exit Sub
End If
inx = temp + 1
Dim x As Integer = (lstMenu.SelectedIndices.C
While x >= 0
lstMenu.Items.RemoveAt(lst
System.Math.Max(System.Thr
End While
Beep()
lstMenu.Items.Insert(inx, lvi)
Thanks
PBLack
- PS I have another question of a similar nature involving adding items to a listview
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks