Listbox items
Posted: Mon Jan 16, 2017 8:16 pm
The listbox control below has an items array literally declared within. A function to return the value was also written as shown.
1.)
Can that items entry be an array variable, example
aTypes :={"Financial","Commercial","Technical","Entertainment"}
.
.
.
ITEMS aTypes
If so, can the same listbox be invoked and re-used with different arrays, each containing other items lists?
2) If you want to select an "item", do you have to write a function like I did to fetch the selection so that it can be
displayed elsewhere?
DEFINE LISTBOX L_Type
ROW 73
COL 70
PARENT Form_2
WIDTH 200
HEIGHT 35
VALUE 0
VISIBLE .F.
ON LOSTFOCUS GetcType()
ITEMS {"Financial","Commercial","Technical","Entertainment"}
END LISTBOX
*-----------------------------------------------------
Function GetcType()
*-----------------------------------------------------
Local nTypeIndex:=0, cTypex
form_2.L_Type.visible:=.F. //hide the listbox after using it
form_2.T_Type.visible:=.T. //show the textbox with the value over top of hidden listbox
nTypeIndex:=Form_2.L_type.value // get litbox index to "items"
cTypex:=aTypes[nTypeIndex] // find out its value from a LOCAL array that has the same values as the ListBox
form_2.T_Type.Value:=cTypex // display the selected "Item"
return
1.)
Can that items entry be an array variable, example
aTypes :={"Financial","Commercial","Technical","Entertainment"}
.
.
.
ITEMS aTypes
If so, can the same listbox be invoked and re-used with different arrays, each containing other items lists?
2) If you want to select an "item", do you have to write a function like I did to fetch the selection so that it can be
displayed elsewhere?
DEFINE LISTBOX L_Type
ROW 73
COL 70
PARENT Form_2
WIDTH 200
HEIGHT 35
VALUE 0
VISIBLE .F.
ON LOSTFOCUS GetcType()
ITEMS {"Financial","Commercial","Technical","Entertainment"}
END LISTBOX
*-----------------------------------------------------
Function GetcType()
*-----------------------------------------------------
Local nTypeIndex:=0, cTypex
form_2.L_Type.visible:=.F. //hide the listbox after using it
form_2.T_Type.visible:=.T. //show the textbox with the value over top of hidden listbox
nTypeIndex:=Form_2.L_type.value // get litbox index to "items"
cTypex:=aTypes[nTypeIndex] // find out its value from a LOCAL array that has the same values as the ListBox
form_2.T_Type.Value:=cTypex // display the selected "Item"
return