Hi
I have the following code behind a button that will select the next item in a listbox and add it to a text box. The problem is that when i clik the button to go to the second item the code skips the second item and goes to the third item
For i As Integer = ListBox1.Items.Count - 1 To 1 Step -1
ListBox1.SetSelected(i, ListBox1.GetSelected(i - 1))
Dim lstitem as string
lstitem = (ListBox1.SelectedItem) '.ToString
If lstitem = "" Then
Exit Sub
End If
TextBox1.Text = lstitem
Next i
ListBox1.SetSelected(0, False)
[/color red]
For the Form Load i have the following code
ListBox1.SetSelected("0", True)
TextBox1.Text = ListBox1.Items.Item(0)[/color red]
Where am i going wrong
Thanks
I have the following code behind a button that will select the next item in a listbox and add it to a text box. The problem is that when i clik the button to go to the second item the code skips the second item and goes to the third item
For i As Integer = ListBox1.Items.Count - 1 To 1 Step -1
ListBox1.SetSelected(i, ListBox1.GetSelected(i - 1))
Dim lstitem as string
lstitem = (ListBox1.SelectedItem) '.ToString
If lstitem = "" Then
Exit Sub
End If
TextBox1.Text = lstitem
Next i
ListBox1.SetSelected(0, False)
[/color red]
For the Form Load i have the following code
ListBox1.SetSelected("0", True)
TextBox1.Text = ListBox1.Items.Item(0)[/color red]
Where am i going wrong
Thanks