deselect item in list box

  • Thread starter Thread starter GJP
  • Start date Start date
G

GJP

Hello.

I have two list boxes. One with a picture name, and one for the ID of that
picture (both coming from a database).

The user selects the name of the picture and presses a button, the picture
and the picture ID are then moved to other list boxes. This works ok, but
once this has been done, i dont want to delete the item from the origional
listbox, i just want to deselect it, but i cant seem to do this.

Here is the code for when the button is clicked:

'move items
Me.lstSSPics.Items.Add(Me.lstAvailable.SelectedItem)
Me.lstSSPicsID.Items.Add(Me.lstAvailableID.Items.Item(Me.lstAvailable.Select
edIndex))
'change move button enabled
Me.btnMove.Enabled = False
'deselect item ***this bit dont work***
lstSSPics.SelectedIndex = -1
lstSSPicsID.SelectedIndex = -1
'run enableAdd
enableAdd()

As you can see, i have tried getting around it by setting selectedIndex
to -1, but this does not work.

Any ideas?
Thank you in advance
Gavin.
 
* "GJP said:
Me.btnMove.Enabled = False
'deselect item ***this bit dont work***
lstSSPics.SelectedIndex = -1
lstSSPicsID.SelectedIndex = -1
'run enableAdd
enableAdd()

As you can see, i have tried getting around it by setting selectedIndex
to -1, but this does not work.

Set 'SelectedIndex' to -1 /twice/ for the same listbox.
 
Back
Top