L
Loogie
Hi
I have a listview in which the user can promote or demote items in it by
clicking an up or down button. Problem is that my code will not work in
VB.Net compact framework. This code should always ensure that the
selected item is visible. Can someone help me out please?
Thanks
:L
Private Sub picUp_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles picUp.Click
'sort em
If lsvHead.SelectedIndices.Count = 0 Then
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lsvHead.Items(lsvHead.SelectedIndices(0))
Dim inx As Integer
Dim temp As Integer
temp = lsvHead.Items.IndexOf(lvi)
If temp = 0 Then
Beep()
Exit Sub
End If
inx = temp - 1
Dim x As Integer = (lsvHead.SelectedIndices.Count - 1)
While x >= 0
lsvHead.Items.RemoveAt(lsvHead.SelectedIndices(x))
System.Math.Max(System.Threading.Interlocked.Decrement(x),
x + 1)
End While
Beep()
lsvHead.Items.Insert(inx, lvi)
lsvHead.Items(inx).EnsureVisible() '- not supported in compact
framework
lsvHead.Items(inx).Selected = True
End Sub
I have a listview in which the user can promote or demote items in it by
clicking an up or down button. Problem is that my code will not work in
VB.Net compact framework. This code should always ensure that the
selected item is visible. Can someone help me out please?
Thanks
:L
Private Sub picUp_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles picUp.Click
'sort em
If lsvHead.SelectedIndices.Count = 0 Then
Beep()
Exit Sub
End If
Dim lvi As ListViewItem = lsvHead.Items(lsvHead.SelectedIndices(0))
Dim inx As Integer
Dim temp As Integer
temp = lsvHead.Items.IndexOf(lvi)
If temp = 0 Then
Beep()
Exit Sub
End If
inx = temp - 1
Dim x As Integer = (lsvHead.SelectedIndices.Count - 1)
While x >= 0
lsvHead.Items.RemoveAt(lsvHead.SelectedIndices(x))
System.Math.Max(System.Threading.Interlocked.Decrement(x),
x + 1)
End While
Beep()
lsvHead.Items.Insert(inx, lvi)
lsvHead.Items(inx).EnsureVisible() '- not supported in compact
framework
lsvHead.Items(inx).Selected = True
End Sub