Groups | Blog | Home
all groups > vb.net > april 2004 >

vb.net : deselect item in list box


GJP
4/26/2004 9:24:22 PM
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.

--
Free sweets for me and you when you join
http://www.sweetcollect.com/?referer=scaredycat
---
Do something amazing give Blood
http://www.blood.co.uk

GJP
4/26/2004 10:01:08 PM
Thanks, ill give it a go!
--
Free sweets for me and you when you join
http://www.sweetcollect.com/?referer=scaredycat
---
Do something amazing give Blood
http://www.blood.co.uk

[quoted text, click to view]

hirf-spam-me-here NO[at]SPAM gmx.at
4/26/2004 10:45:52 PM
* "GJP" <gavin@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
[quoted text, click to view]

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

--
Herfried K. Wagner [MVP]
hirf-spam-me-here NO[at]SPAM gmx.at
4/27/2004 12:27:28 AM
* "GJP" <gavin@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
[quoted text, click to view]

Here it is:

BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
<URL:http://support.microsoft.com/?id=327244>

--
Herfried K. Wagner [MVP]
GJP
4/27/2004 6:34:49 PM
got it working. cheers.

Gav

--
Free sweets for me and you when you join
http://www.sweetcollect.com/?referer=scaredycat
---
Do something amazing give Blood
http://www.blood.co.uk
[quoted text, click to view]

AddThis Social Bookmark Button