Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List box
Message
From
28/01/2008 19:18:32
 
 
To
28/01/2008 18:57:05
Randy Hooper
Ranco Business Software
Tampa, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01286399
Message ID:
01286409
Views:
25
Update: I just noticed that you said your listbox must have 3 columns but only populate 2. What is the 3rd column for? The below example populates the listbox with the values in column2 and column3, but you can get the idea I think. Also, it is not necessary to scan the table to populate the array but I used it because you were scanning to make it easier to understand.

You mean something like this?
set safety off
oform = createobject('testform')
oform.show()
read events


DEFINE CLASS testform AS form


	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	DIMENSION colvalues[1]


	ADD OBJECT list1 AS listbox WITH ;
		BoundColumn = 1, ;
		ColumnCount = 2, ;
		ColumnWidths = "120,120", ;
		RowSourceType = 5, ;
		RowSource = "thisform.colvalues", ;
		Height = 170, ;
		Left = 25, ;
		Top = 20, ;
		Width = 288, ;
		BoundTo = .T., ;
		Name = "List1"


	ADD OBJECT label1 AS label WITH ;
		Caption = "Value:", ;
		Height = 17, ;
		Left = 36, ;
		Top = 204, ;
		Width = 40, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		Caption = "DisplayValue:", ;
		Height = 17, ;
		Left = 36, ;
		Top = 228, ;
		Width = 96, ;
		Name = "Label2"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 86, ;
		Top = 201, ;
		Width = 262, ;
		Name = "Text1"


	ADD OBJECT text2 AS textbox WITH ;
		Height = 23, ;
		Left = 149, ;
		Top = 225, ;
		Width = 199, ;
		Name = "Text2"


	PROCEDURE Init
		CREATE TABLE testtable (ccol1 c(20), ccol2 c(20), ccol3 c(20))
		For i = 1 TO 10
		   m.ccol1 = 'column 1 record '+ALLTRIM(STR(i))
		   m.ccol2 = 'column 2 record '+ALLTRIM(STR(i))
		   m.ccol3 = 'column 3 record '+ALLTRIM(STR(i))
		   insert INTO testtable FROM memvar
		endfor
		select testtable
		dimension this.colvalues(RECCOUNT('testtable'),2)
		SCAN
			this.colvalues(RECNO('testtable'),1) = testtable.ccol2
			this.colvalues(RECNO('testtable'),2) = testtable.ccol3
		ENDSCAN
		this.list1.requery()
		USE IN testtable
		this.list1.listindex = 1
		thisform.text1.value = this.list1.value
		thisform.text2.value = this.list1.displayvalue
		thisform.text1.refresh()
		thisform.text2.refresh()
	ENDPROC


	PROCEDURE list1.Valid
		DODEFAULT()
		thisform.text1.value = this.value
		thisform.text2.value = this.displayvalue
		thisform.text1.refresh()
		thisform.text2.refresh()
	ENDPROC


	PROCEDURE list1.Click
		DODEFAULT()
		thisform.text1.value = this.value
		thisform.text2.value = this.displayvalue
		thisform.text1.refresh()
		thisform.text2.refresh()
	ENDPROC
	
	PROCEDURE destroy
		DODEFAULT()
		CLEAR events
	ENDPROC


ENDDEFINE
>I am using a parameterized view, view is working fine, need to have 3 columns in my list box, need to populate column2 and column3.
>
>
>>How many items in total will there be? Is it an unknown? why not set the listbox's rowsource as the table or populate an array with the items from the table?
>>
>>
>>>Have a local view and I am wanting to populate a list box with 3 columns. Code I am using,
>>>
>>>
>>>scan
>>>   citem1 = alltrim(field1)
>>>   citem2 = alltrim(field2)
>>>   citem3 = alltrim(field3)
>>>
>>>   thisform.list1.addItem(citem)
>>>
>>>   ** how do i add to my code to add citem2, citem3 to the list box
>>>endscan
>>>
>>>
>>>thanks
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform