Page 1 of 1

TListBox:Select() bug

Posted: Thu Feb 16, 2006 12:52 pm
by Enrico Maria Giordano
When the listbox is multiselection Select() method doesn't work. This is the sample. The first item is not selected at start:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oLbx

    LOCAL cVar := ""

    DEFINE DIALOG oDlg

    @ 1, 1 LISTBOX oLbx VAR cVar ITEMS { "Bert", "Carl", "William" }

    oLbx:nStyle += LBS_MULTIPLESEL

    @ 3, 1 BUTTON "&Close" ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             ON INIT oLbx:Select( 1 );
             CENTER

    RETURN NIL
A possible fix is to change the Select() method:

Code: Select all

METHOD Select( nItem ) INLINE If( ! ::IsMultipleSel(), ::SendMsg( 
LB_SETCURSEL, nItem - 1, 0 ), ::SetSel( nItem ) ),;
                                 ::Change()
EMG