Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Populating List Boxes
Message
 
 
À
14/12/2000 10:23:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00453352
Message ID:
00453518
Vues:
21
>Has anyone found a way to populate a multiselect listbox with one or more items already marked as selected?

Hi Ed,

This is method from one my working class. I believe, I call this method from ListBox.Init, but I might be wrong, because the class itself is really complicated. It saves and restores user's choices via MetaFile.
********************************************************************
*  Description.......: BTCC_MultiList.BTC_ListSelect: method to select a comma-delimited list of codes
*  Calling Samples...:
*  Parameter List....: list_arg
*  Created by........: MDA
*  Modified by.......: Nadya Nosonovsky 01/14/2000 04:07:16 PM
********************************************************************
* 8/4/99: Adapted from preliminary logic for handling the Counties listbox.
* 12/14/99 NN changed the code to better handle lost of items selected (AT instead of INLI)
* This method is used for state-saving/restoration of the listbox.
*
* Note that the behavior of this method is additive, to allow for anticipated need to
* split up steps due to VFP's 256 character macro/expression length limit.

lparameters list_arg	&& takes 1 required arg
* list_arg:				list of codes, in a form suitable for arglist to inlist().
if alen(this.btcValArray) <= 1		&& array is empty
	return							&& no-op
endif

with this
	if empty(list_arg)
		list_arg=.btcCrit
	endif

	local n, lnSel,  lnCodes, lnLen

* check for empty array special case

	lnLen=alen(.btcValArray, 1)
* loop over the array, checking each item against the given list
	for n = 1 to lnLen				&& cycle over rows
		if at(.btcValArray[m.n, 2], list_arg)>0     && this item is to be selected
			.Container1.List1.selected(m.n) = .t.	&& flag list item as Selected
		endif
	endfor

	if !empty(.TableName)
		lnSel=select() && save current area

		select (.TableName)

		if reccount()<1 and !empty(list_arg) && First time
			local array laCodes[1]
			lnCodes=aparser1(@laCodes, list_arg,',')
			for i=1 to lnCodes
				insert into (.TableName) values (laCodes[i])
			next
			if !empty(.InputClass)
				lObj=evaluate('this.container1.'+.InputClass+'1')
				lObj.requery()
			endif
		endif
		select (lnSel) && return to previous area
	endif
endwith
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform