View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
kirkm[_8_] kirkm[_8_] is offline
external usenet poster
 
Posts: 166
Default Selected... or not ??

On Thu, 4 Jun 2009 09:46:11 +0100, "Patrick Molloy"
wrote:

Thanks for the rundown. Learning more all the time.. ceratinly all
this multiple firing and what's called and in what sequencecan be hard
to follow. By the waycould you explain what 'Control Source' is in
relation to a listbox, please?
Not the Excel help, which I can't fathom, but in normal English? :)

Thanks... there was another thread but it went cold, and there
was no answer.
Cheers - Kirk



any time you click an item in a listbox control, the change event fires.
when an item is selected using the SELECTED property, it also fires the
change event. The change event will fire even if the item state doesn't
change

so
listbox1.selected(5)=True
listbox1.selected(5)=True
will fire twice even though the 2nd line doesn't change the property value.
imagine it like the worksheet change event. it will fire if you type A into
a cell. it will fire again if you type A into the same cell


for a multiselect you test if an item is selected

with listbox1
for i = 0 to .listcount-1 'zero based
if .selected(i) then
'item i is selected
end if
next
end with

an item is selected by using this code
listbox1.selected(index)=True
and deselected by
listbox1.selected(index)=False