hi
again problem with listbox :(
i really tried to find help from google but i couldn't
My problem is this :
I have 3 listboxes
quantity , MenuItem , Price
then user must enter data into them
then when user clicks on one item in one listbox the same index items from 2 other listboxes must also be selected
problem now begins
there must be a button to Clear these 3 selected items
what happens in my code is that
i wrote this :
Private Sub lstQuantity_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstQuantity.SelectedIndexChanged
btnRemoveLine.Enabled = True
lstMenuItem.SelectedIndex = lstQuantity.SelectedIndex
lstPrice.SelectedIndex = lstQuantity.SelectedIndex
End Sub
Private Sub lstMenuItem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstMenuItem.SelectedIndexChanged
btnRemoveLine.Enabled = True
lstQuantity.SelectedIndex = lstMenuItem.SelectedIndex
lstPrice.SelectedIndex = lstMenuItem.SelectedIndex
End Sub
Private Sub lstPrice_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstPrice.SelectedIndexChanged
btnRemoveLine.Enabled = True
lstQuantity.SelectedIndex = lstPrice.SelectedIndex
lstMenuItem.SelectedIndex = lstPrice.SelectedIndex
End Sub
then the code for btnRemoveLine is this :
]
If lstMenuItem.SelectedIndex <> -1 And lstPrice.SelectedIndex <> -1 And lstQuantity.SelectedIndex <> -1 Then
lstPrice.Items.Remove(lstPrice.SelectedItem)
lstMenuItem.Items.Remove(lstMenuItem.SelectedItem)
lstQuantity.Items.Remove(lstQuantity.SelectedItem)
End If
when first it removes the SelectedItem in lstPrice it goes again to Private Sub lstPrice_SelectedIndexChanged and again sets the SelectedIndex so the 2 other list boxes will be unselected because Selected Index in all 3 list boxes are equal and when it removes one of them the 2 other indexes will be equal to -1
please let me know if i didn't explain the problem well
I need urgent help :(
tnQ all