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
Listbox items
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Listbox items
Sorry, I did not understand it...
Would you make a practical example to make easier the test ?
Would you make a practical example to make easier the test ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Listbox items
Yes! You can use any array of items to an existing listbox.
For that you need to write coding for adding the array items. It can be done in a small function also. For example,
Code: Select all
aMyArray := { 'Item1', 'Item2', 'Item3' }
myform.mylistbox.deleteallitems
for i := 1 to len( aMyArray )
myform.mylistbox.additem( aMyArray[ i ] )
next i
Code: Select all
aMyArray := { 'Item1', 'Item2', 'Item3' }
Set_Array_to_ListBox( 'myform', 'mylistbox', aMyArray )
function Set_Array_to_ListBox( cFormName, cListBox, aArray )
local i
doMethod( cFormName, cListBox, 'DELETEALLITEMS' )
for i := 1 to len( aArray )
doMethod( cFormName, cListBox, 'ADDITEM', aArray[ i ] )
next i
return nil
No. Need not be!bluebird wrote: ↑Mon Jan 16, 2017 8:16 pm 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
Code: Select all
Function GetcType()
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
form_2.T_Type.Value:=form_2.l_type.item( form2.l_type.value ) // display the selected "Item"
return
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.