Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiselect listbox without using CTL button
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00881108
Message ID:
00881377
Views:
17
Eric,

I would agree with Davids suggestion, however if you still wanted to use a listbox then you can add checkbox selection to it to give a visual clue to the selected state of an item. The following is a simple example of how to achieve this and relies on the existance of an aItemSelected[] property which holds the checked state for each item.
*!* Init()
This.Picture = "bitmaps\uncheck.bmp"

*!* Click()
if LastKey() != 5 AND LastKey() != 24
   *!* If unchecked then check.
   if This.aItemSelected[This.ListItemID] = 0
      This.Picture(This.ListItemID) = "bitmaps\checkbox.bmp"
      This.aItemSelected[This.ListItemID] = 1
   else
      *!* If checked the uncheck.
      if This.aItemSelected[This.ListItemID] = 1
         This.Picture(This.ListItemID) = "bitmaps\uncheck.bmp"
         This.aItemSelected[This.ListItemID] = 0
      endif
   endif
endif

*!* KeyPress()
LPARAMETERS nKeyCode, nShiftAltCtrl

if nKeyCode = 32
   *!* If unchecked then check.
   if This.aItemSelected[This.ListItemID] = 0
      This.Picture(This.ListItemID) = "bitmaps\checkbox.bmp"
      This.aItemSelected[This.ListItemID] = 1
   else
      *!* If checked the uncheck.
      if This.aItemSelected[This.ListItemID] = 1
         This.Picture(This.ListItemID) = "bitmaps\uncheck.bmp"
         This.aItemSelected[This.ListItemID] = 0
      endif
   endif
endif

*!* Refresh()
LOCAL lnItem

for lnItem = 1 to ThisForm.NumLstItm
   if This.aItemSelected[lnItem] = 0
      This.Picture(lnItem) = "bitmaps\uncheck.bmp"
   else
      This.Picture(lnItem) = "bitmaps\checkbox.bmp"
   endif
endfor
Regards
Neil
Previous
Reply
Map
View

Click here to load this message in the networking platform