27-03-13, 05:03 AM
تفضل اخى هذا لا يعطى اخطاء اذا كانت الايتم المختارة هيا الاخيرة ويقوم بحذفها
كود :
For i As Integer = 0 To ListBox1.Items.Count - 1
If ListBox1.SelectedIndex = i Then
If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
ListBox1.Items.RemoveAt(i)
ListBox1.SelectedIndex = (i - 1)
Else
ListBox1.Items.RemoveAt(i)
ListBox1.SelectedIndex = (i)
End If
End If
Next