Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListBox doesn't want to clear selections
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
ListBox doesn't want to clear selections
Miscellaneous
Thread ID:
00408806
Message ID:
00408806
Views:
70
Hi everybody,

I found a problem with ListBox, which I can not resolve.
I have a container class, which has MultiSelect ListBox, Command Button (Clear) and Exclude CheckBox. If I select something in ListBox, when hit Clear button, it clears ListBox - no problem. But if I open the form with predefined selections and hit Clear button without clicking on ListBox first, my selection still remains.
I tried in CommandButton:
List.Click
List.SetFocus
List.ListIndex=0

Nothing works!!!

This 'hole' in my interface really upsets me :(

This is the code in CommandButton click:
********************************************************************
*  Description.......: Command1.Click - Clear all Selections
*  Calling Samples...: 
*  Parameter List....: 
*  Created by........:  
*  Modified by.......: Nadya Nosonovsky 03/14/2000 06:13:57 PM
********************************************************************
* 8/4/99: support an easy way to clear all selected items.
*     Adapted from preliminary logic for handling the Counties listbox.
* 8/7/99: added tie-in to new btc_cascade method, for propagating changes as necessary.
with this.parent.parent
     this.enabled=.f.          && should cause this button to become disabled
     .container1.list1.SetFocus() && Fake click

     .BTC_ListClear()          && clear all selections in the listbox
     if .hasdependants
         .BTC_Cascade()          && force re-init of any dependent controls
     endif
endwith
This is the code in btc_ListClear:
********************************************************************
*  Description.......: BTCC_MultiList.BTC_ListClear: method to clear all selections in this criterion's listbox
*  Calling Samples...:
*  Parameter List....:
*  Created by........: MDA
*  Modified by.......: Nadya Nosonovsky 12/29/1999 04:21:56 PM
********************************************************************
* 8/4/99: Adapted from preliminary logic for handling the Counties listbox.

local n, lnSel

* not sure if the following is necessary, but may avoid flakiness and can't hurt
with this.container1.list1
            local n
            for n=.ListCount to 1 step -1
                .selected(n)=.f.
            endfor
            .refresh()  
endwith

with this

     if !empty(.CursorName) && Clear cursor content
          lnSel=select() && save current area
          select (.CursorName)
          zap
          select (lnSel) && restore previous selection
     endif

endwith
This is the code in List1.Refresh()
********************************************************************
* Description.......: List1.Refresh()
* Calling Samples...:
* Parameter List....:
* Created by........: MDA
* Modified by.......: Nadya Nosonovsky 01/18/2000 10:47:56 AM
********************************************************************
* 8/4/99: support pseudo-disablement of listbox.
* Adapted from preliminary logic for handling the Counties listbox.
* 8/5/99: use alternate color (red) to distinguish exclusion from selection (blue).

* maintain pseudo-disablement of the listbox, even if parent.setall(...) disabled it
with this

if .parent.parent.visible && don't need to refresh if it's unvisible
.enabled = .t. && always keep the listbox actually enabled


* fake up disablement of listbox so as to keep selections visible
if .parent.enabled && parent container is enabled
* use default colors (I included all for clarity, but only two of these really change)
*!* this.ItemBackColor = rgb(255,255,255) && white
.itemforecolor = rgb(0,0,0) && black
.selecteditembackcolor = ;
iif(.parent.check1.value=1, rgb(128,0,0), rgb(0,0,128)) && dark red or blue

else && parent container is disabled
* use pseudo-disabled colors for the listbox
*!* this.ItemBackColor = rgb(255,255,255) && white
.itemforecolor = rgb(128,128,128) && gray
.selecteditembackcolor = ;
iif(.parent.check1.value=1, rgb(255,128,128), rgb(128,128,255)) && light red or blue
*!* this.SelectedItemForeColor = rgb(255,255,255) && white
endif
dodefault()
endif
endwith

Could somebody help me, please?

Thanks in advance
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform