468,241 Members | 1,555 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

deselect item in list box

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.SelectedIte m)
Me.lstSSPicsID.Items.Add(Me.lstAvailableID.Items.I tem(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
Nov 20 '05 #1
4 6845
* "GJP" <ga***@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
GJP
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

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
* "GJP" <ga***@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3
* "GJP" <ga***@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
Thanks, ill give it a go!


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]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
GJP
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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
* "GJP" <ga***@gMYSECONDNAME4397.fsnet.co.uk> scripsit:
Thanks, ill give it a go!


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]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Christian Dokman | last post: by
4 posts views Thread by Bill Nguyen | last post: by
7 posts views Thread by deepagulati | last post: by
1 post views Thread by Bailu | last post: by
reply views Thread by bscrivner | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.