Problem Displaying Selected Item in Listview - Is there and alternatefor .EnsureVisible() in compact

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
 
L

Loogie

Loogie said:
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
Cancel this I found the error in my syntax:

lsvHead.Items(inx).EnsureVisible() will work in regular vb.net but in
compact framework has to be written as:

lsvHead.EnsureVisible(inx)


:L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top