Ok, George, the simplest way is the following. But, if you have a huge number of entries in the listbox it may bog down.....
ThisForm.cmdButton.Refresh()
nSelCount=0
lEnabled=.F.
FOR i = 1 TO ThisForm.Listbox.ListCount
IF ThisForm.Listbox.Selected(i)
nSelCount=nSelCount+1
IF nSelCount >= 2
lEnabled=.T.
ENDIF
ENDIF
ENDFOR
This.Enabled=lEnabled
>Hi, all!
>
>Here is my problem:
>
>I have a multiselect listbox on a form. There is also a command button on the form. The command button should only be enabled if two or more list items are selected.
>
>Is there any event which fires as list items are selected/unselected?
>
>I tried putting some code in the mousedown/mouseup events. This works unless the user uses the keyboard to select items.
>
>I also tried creating a custom listbox class, with a selected_assign() method. This method doesn't seem to ever fire. I was hoping that as the selected() property of the listbox changed, the assign method would fire. But it doesn't.
>
>Any ideas?
>
>- George
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05