slowNsteady
Programmer
Hi friends
I have a listbox in form2 and the items are populated to it from another form named form1. In form2 i have created a button named btnUP. When we click the btnUP then the highlighted selected item in the listbox moves one level up. this is working fine.
But the problem is only the value is moving up but not the highlight.
i have also set the setselect property to true
"List1.SetSelected(i - 1, True)" but no use
don know wat is wrong with the code.But it is not working
So here is my code
Thanks in advance
Sri
I have a listbox in form2 and the items are populated to it from another form named form1. In form2 i have created a button named btnUP. When we click the btnUP then the highlighted selected item in the listbox moves one level up. this is working fine.
But the problem is only the value is moving up but not the highlight.
i have also set the setselect property to true
"List1.SetSelected(i - 1, True)" but no use
don know wat is wrong with the code.But it is not working
So here is my code
Code:
Private Sub btnUP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUP.Click
i = 0
If Not List1.Items.Count = 0 Then
For i = 0 To List1.Items.Count
If List1.SelectedIndex = i Then 'identify the selected item
'swap with the top item(move up)
If i > 0 And Not i = List1.SelectedIndex - 1 Then
Item_Obj = List1.SelectedItem
List1.Items.Remove(Item_Obj)
List1.Items.Insert(i - 1, Item_Obj)
List1.SetSelected(i - 1, True)
End If
End If
Next
End If
End Sub
Thanks in advance
Sri