# Wx::CheckListBox (maybe all ControlsWithItems?) oddities

**URL:** <https://www.ruby-forum.com/t/wx-checklistbox-maybe-all-controlswithitems-oddities/207954>\
**Category:** wxRuby\
**Created:** [June 7, 2011, 12:33am UTC](https://www.ruby-forum.com/t/wx-checklistbox-maybe-all-controlswithitems-oddities/207954 "2011-06-07T00:33:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 7, 2011, 12:33am UTC](https://www.ruby-forum.com/t/wx-checklistbox-maybe-all-controlswithitems-oddities/207954/1 "2011-06-07T00:33:44Z")

</div>

Hi,

OSX 10.6.7 w/ wxRuby 2.0.1 from rubyforge, reproducible on Windows 7.

I’m using a Wx::CheckListBox with

- LB\_MULTIPLE
- LB\_NEEDED\_SB
- LB\_SINGLE
- LB\_SORT

I can reproduce the following behavior:

1.) Single selection doesn’t work. No matter what I do, the CheckListBox  
will always add to the selection, even when completely without an event  
handler.

This is my remedy code:

def on\_select\_list event  
index = event.get\_index()  
@checklistbox.get\_selections().each {|x| @checklistbox.deselect x }  
@checklistbox.select index  
# … do stuff here  
end

2.) The sorting algorithm will sort the listbox strings but, while  
auto-sorting after an append(string label, void clientdata), lose  
association with the client (void) data.

Example scenario

1. CLB empty
2. append (“bbb”, hash 2)
3. append (“aaa”, hash 1)

after these three operations, the CLB always looks like

[0] string: “aaa” / data: hash 2  
[1] string: “bbb” / data: hash 1

What am I doing wrong?

Thanks,  
T
