Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric data in a ListBox
Message
From
04/03/2011 05:36:29
 
 
To
03/03/2011 12:30:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01502526
Message ID:
01502612
Views:
32
>Hello,
>
>I'm having a problem getting numeric data to stay numeric in a ListBox. I have a 3 column array which I am using as the rowsource and the data types are Col1-Char, Col2-Char, Col3-Numeric. The 3rd column is being converted to Character in the ListBox. I've tried this with BoundTo set to .T. and .F. with the same result.
>
>Here is an example of my code, and the data result:
>
>this.lstChoices.rowsourcetype = 5 &&array
>this.lstChoices.rowsource = "aChoices" &&array
>this.lstChoices.BoundColumn = 3
>this.lstChoices.ColumnCount = 3
>this.lstChoices.ColumnWidths = "50,400,0"
>this.lstChoices.NumberOfElements = 3
>
>Data
>aChoices[1,1] "Tom " C
>aChoices[1,2] "Smith " C
>aChoices[1,3] 145 N
>
>Result
>this.lstChoices.List(1,1) "Tom " C
>this.lstChoices.List(1,2) "Smith " C
>this.lstChoices.List(1,3) " 145" C
>
>
>I know I can just convert the numeric data in the array to character data and work with it that way, but I prefer not to have to do that and I very interested to find out what I'm doing wrong.
>
>Thanks in advance,
>Larry

the only way is to bind the ListBox controlSource to a Numeric Field.
With a variable or property you must to stay away to null value
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	Height = 505
	Width = 795
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT list1 AS listbox WITH ;
		BoundColumn = 2, ;
		ColumnCount = 2, ;
		RowSourceType = 6, ;
		RowSource = "tableList.F1,f2",;
		ControlSource = "tableTarget.fx", ;
		Height = 192, ;
		Left = 60, ;
		Top = 72, ;
		Width = 204, ;
		BoundTo = .T., ;
		Name = "List1"


	PROCEDURE Load
		CREATE CURSOR tableList (f1 C(10),f2 N(10))
		INSERT INTO tableList VALUES ('Item1',31)
		INSERT INTO tableList VALUES ('Item2',52)

		CREATE CURSOR tableTarget (fx N(10))
		APPEND BLANK
	ENDPROC


	PROCEDURE list1.Click
		WAIT windows VARTYPE(this.Value)+' '+CAST(this.Value AS M)
	ENDPROC

ENDDEFINE
Previous
Reply
Map
View

Click here to load this message in the networking platform