Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Deselect Selecteditem in a Listbox


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2007, 01:39 PM
Newbie
 
Join Date: Jun 2007
Posts: 4
Default Deselect Selecteditem in a Listbox

Hello!

I'm still working on my selection form..
Which has got a listbox. When nothing is selected the selectedindex = -1.
Now when i select something i can't deselect it anymore..
So I made up this deselect button with the following click-event:

myListbox.selectedIndex = -1

But this produces an [runtime] error everytime.
Does anybody have a suggestion?

Ghislain
Reply With Quote
  #2 (permalink)  
Old 06-27-2007, 01:46 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,132
Default

Try to remove the selected item and then insert it again.
Reply With Quote
  #3 (permalink)  
Old 06-27-2007, 01:50 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,313
Default

If You don't require multiple selections then a radio button should be best for you....Check this code:
Attached Files
File Type: zip teste.zip (1.1 KB, 15 views)
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #4 (permalink)  
Old 06-27-2007, 04:11 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 636
Default

Hi ghislain,

if I want to give the user the chance to deselect a listbox entry I'll do the following:
I add a "dummy"-entry at the first (or last) position of the listbox named "<no selection>" (or something like that) and pre-select this entry before showing the listbox.
Now you can proof during runtime, if the first (or last) entry is selected, which means, nothing is selected ...


specci48
Reply With Quote
  #5 (permalink)  
Old 06-27-2007, 07:25 PM
Newbie
 
Join Date: Jun 2007
Posts: 4
Default

Thanks for all the replies.
For the time being I will just refill my listbox. Which does the same trick as well. But it might become too slow when my list becomes longer and longer..
I hope in the future the functionality to deselect-all will be implemented..
Thanks!
Reply With Quote
  #6 (permalink)  
Old 06-27-2007, 07:45 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,313
Default

Have you tryied to set the index to -1?
That is , at least i think it is, the start point of any un-selected index..
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #7 (permalink)  
Old 06-29-2007, 12:01 AM
Junior Member
 
Join Date: Apr 2007
Location: Leicester, UK
Posts: 16
Default

Ghislain started off setting the index to -1 but, as mentioned, that gives a runtime error. If you trap that error with an empty error handler you'll get the deselection without the error being reported.

Sub EventsList_LostFocus
ErrorLabel(ErrHandler)
EventsList.SelectedIndex = -1
return
ErrHandler:
End Sub

If your deselection comes within other code you'll need to have a goto to just after the selectedindex = -1 code.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox and enter key tsteward Questions & Help Needed 2 10-14-2008 07:30 AM
Lookup Contacts using a listbox thartung Questions & Help Needed 9 02-27-2008 10:16 AM
How to fix ListBox Items? Stellaferox Questions & Help Needed 12 02-22-2008 10:50 AM
Listbox difficulties. dan kabestan Questions & Help Needed 2 12-15-2007 07:24 PM
listbox = arraylist ? sloopa Questions & Help Needed 1 05-07-2007 01:38 PM


All times are GMT. The time now is 11:34 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0