TListBox:Select() bug

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

TListBox:Select() bug

Post 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
Post Reply