Microsoft KB Archive/104258: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 20: | Line 20: | ||
== MORE INFORMATION == | == MORE INFORMATION == | ||
There are several different methods of creating a multiple-selection list object. The following example demonstrates how to make selections in an array. (In the example, the array is called | There are several different methods of creating a multiple-selection list object. The following example demonstrates how to make selections in an array. (In the example, the array is called "test".) The selections are marked by a check mark [CHR(251)], and then the selection is displayed when the Done button is chosen. The VALID routine for the push button sorts the array and stores the selected options in a variable. All options that were selected are stored in the "checked" variable. | ||
=== Notes === | === Notes === | ||
Line 29: | Line 29: | ||
<p>CLOSE DATABASE CLEAR</p> | <p>CLOSE DATABASE CLEAR</p> | ||
<p>USE tutorial\customer *** Create array test to store the field CNO from database COPY TO ARRAY test FIELDS cno *** Store a space as the first character of every element of the *** array. FOR i = 1 TO ALEN(test)</p> | <p>USE tutorial\customer *** Create array test to store the field CNO from database COPY TO ARRAY test FIELDS cno *** Store a space as the first character of every element of the *** array. FOR i = 1 TO ALEN(test)</p> | ||
<pre> test(i) = | <pre> test(i) = " " + test(i)</pre> | ||
<p>ENDFOR *** Initialize variables</p> | <p>ENDFOR *** Initialize variables</p> | ||
<pre> selected = 0 && Variable to store number of selected items | <pre> selected = 0 && Variable to store number of selected items | ||
checked = | checked = " " && Variable to store selected items | ||
DEFINE WINDOW test FROM 0,0 TO 17,20 TITLE | DEFINE WINDOW test FROM 0,0 TO 17,20 TITLE "Test Application" | ||
MOVE WINDOW test CENTER | MOVE WINDOW test CENTER | ||
ACTIVATE WINDOW test | ACTIVATE WINDOW test | ||
@ 2,2 GET choice FROM test DEFAULT 1 SIZE 10,10 ; | @ 2,2 GET choice FROM test DEFAULT 1 SIZE 10,10 ; | ||
VALID myval() | VALID myval() | ||
@ 14,2 GET button PICTURE | @ 14,2 GET button PICTURE "@* Done" VALID done() DEFAULT 1 | ||
READ CYCLE | READ CYCLE | ||
RELEASE WINDOW test | RELEASE WINDOW test | ||
Line 47: | Line 47: | ||
*** Test to see if item has been selected by checking first | *** Test to see if item has been selected by checking first | ||
*** character | *** character | ||
IF SUBSTR(test(choice),1,1) = | IF SUBSTR(test(choice),1,1) = " " | ||
*** Store check mark as first character of array element | *** Store check mark as first character of array element | ||
*** when item is selected. | *** when item is selected. | ||
Line 56: | Line 56: | ||
*** Store a space as first character of array element | *** Store a space as first character of array element | ||
*** to unselect item. | *** to unselect item. | ||
test(choice) = | test(choice) = " " + SUBSTR(test(choice),2,LEN(test(choice))-1) | ||
*** Decrement number if items selected | *** Decrement number if items selected | ||
selected = selected - 1 | selected = selected - 1 | ||
Line 67: | Line 67: | ||
*** Sort selected items to top if array | *** Sort selected items to top if array | ||
result = ASORT(test,1,ALEN(test),1) | result = ASORT(test,1,ALEN(test),1) | ||
*** Store selected items to variable | *** Store selected items to variable "checked" | ||
FOR i = 1 to selected | FOR i = 1 to selected | ||
*** Substitute any desired code to store selected options | *** Substitute any desired code to store selected options | ||
checked = SUBSTR(test(i),2) + | checked = SUBSTR(test(i),2) + " " + checked | ||
ENDFOR | ENDFOR | ||
RELEASE test | RELEASE test | ||
*** Display selected options | *** Display selected options | ||
WAIT WINDOW | WAIT WINDOW "You selected " + checked | ||
CLEAR READ | CLEAR READ | ||
</pre></li></ul> | </pre></li></ul> |
Revision as of 09:35, 20 July 2020
Sample Code for Creating Multiple-Selection GET List BoxID: Q104258 2.00 2.50 2.50a | 2.50 2.50a 3.00 MS-DOS | WINDOWS The information in this article applies to:
SUMMARYFoxPro does not include a multiple-selection GET object that is activated with a READ command. However, you can create a multiple-selection list object by storing the information that is selected in the VALID clause for the list object, as explained below. MORE INFORMATIONThere are several different methods of creating a multiple-selection list object. The following example demonstrates how to make selections in an array. (In the example, the array is called "test".) The selections are marked by a check mark [CHR(251)], and then the selection is displayed when the Done button is chosen. The VALID routine for the push button sorts the array and stores the selected options in a variable. All options that were selected are stored in the "checked" variable. Notes
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a list popup multi select multi-select multiselect multiseletion KBCategory: KBSubcategory: FxprgGeneral Keywords : kbcode FxprgGeneral Version : 2.00 2.50 2.50a | 2.50 2.50a 3.0 Platform : MS-DOS WINDOWS |
Last Reviewed: May 22, 1998 |