Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox with pre-selected checkboxes?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01136236
Message ID:
01136349
Views:
9
I'd like to add one more wrinkle to this whole scenario. If I pass in my source as a comma delimited list [One,Two,Three,Four] and pass in pre-check items [Two,Three], everything works ... including the check box images being updated.

However, if I pass in a row source of a field [mcategor.desc] and a pre-check item of [CANDIDATE], that's when I have the trouble. The item is "selected" as far as my selection array goes (meaning it is going through my logic and finding the match), its just that the check box picture won't update when using a rowsource of 6.

Is this normal?

>I'm creating a generic form that can be used to present a list to a user. The form uses a listbox with check boxes (many thanks to the "1001 Things ... " team).
>
>One of the parameters passed to the form is the RowSource to be used. In the Init, I set the rowsource for the listbox. This part works great!
>
>However, I want to be able to pre-check some of the items in the list. So, I'm allowing the user to pass a comma-delimited list of items as a parameter to the form. I then run the following code in the form's Init:
>
>*Form::Init
>*-- Set up the RowSource of the ListBox
>DO CASE
>   CASE EMPTY(tcSource)
>
>   CASE [.] $ tcSource
>      this.lstList.RowSource = tcSource
>      this.lstList.RowSourceType = 6
>
>   OTHERWISE
>      this.lstList.RowSource = tcSource
>      this.lstList.RowSourceType = 1
>ENDCASE
>
>*-- My own array for tracking selected items
>DIMENSION this.aItemSel(this.lstList.ListCount)
>FOR x = 1 TO ALEN(this.aItemSel,1)
>   this.aItemSel(x) = .F.
>ENDFOR
>
>*-- Try to pre-select the items
>IF !EMPTY(tcPreSelect)
>   this.cPreSelect = tcPreSelect
>   this._PreSelect
>ENDIF
>*EndInit
>
>*procedure Form::_PreSelect
>IF !EMPTY(this.cPreselect)
>   lnWords = GETWORDCOUNT(this.cPreSelect,[,])
>
>   FOR x = 1 TO lnWords
>      lnWord = ALLTRIM(GETWORDNUM(this.cPreSelect,x,[,]))
>
>      lnMatch = 0
>      FOR y = 1 TO this.lstList.ListCount
>         IF lnWord == ALLTRIM(this.lstList.ListItem(y))
>            lnMatch = y
>            EXIT
>         ENDIF
>      ENDFOR
>
>      IF lnMatch # 0
>         this.lstList.Picture(lnMatch) = "listchk.bmp"
>         this.aItemSel(lnMatch) = .T.
>      ENDIF
>   ENDFOR
>ENDIF
>
>this.lstList.Refresh
>*End_PreSelect
>
>
>If I add a button to the form and have the click event call this._PreSelect, everything works great. Also, the call to _PreSelect does indeed find the matches and set the selected flag in my array. However, setting the picture during Init does not seem to have any affect.
>
>Is there any way to get the listbox to accept different pictures during the form's init? If not, how can I "pre-check" those particular items?
>
>Thanks for your help!
Previous
Reply
Map
View

Click here to load this message in the networking platform