Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox numeric values and speedsearch
Message
From
02/12/2004 12:31:17
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00966403
Message ID:
00966454
Views:
7
Any ideas why this doesn't?
*--testform.prg
CLOSE tables
LOCAL o
o = CREATEOBJECT('testform')
o.Show(1)
o = null
RETURN

DEFINE CLASS testform AS FORM

	DataSession = 2
	Height = 313
	Width = 450
	DoCreate = .T.
	ShowTips = .T.
	BorderStyle = 2
	Caption = "ACORD Forms"
	MaxButton = .F.
	MinButton = .F.
	sortorder = "''"
	Name = "AcordForms"
	windowtype = 1


	ADD OBJECT list1 AS listbox WITH ;
		ColumnCount = 2, ;
		ColumnWidths = "300,130", ;
		RowSourceType = 6, ;
		RowSource = "", ;
		Height = 252, ;
		ColumnLines = .F., ;
		Left = 10, ;
		TabIndex = 1, ;
		ToolTipText = "No Help Available.", ;
		Top = 20, ;
		Width = 434, ;
		Name = "List1"


	ADD OBJECT cmdok AS commandbutton WITH ;
		Top = 286, ;
		Left = 156, ;
		Height = 25, ;
		Width = 65, ;
		Caption = "OK", ;
		Default = .T., ;
		TabIndex = 2, ;
		ToolTipText = "Click to Select from the List", ;
		Name = "cmdOk"


	ADD OBJECT cmdcancel AS commandbutton WITH ;
		Top = 286, ;
		Left = 228, ;
		Height = 25, ;
		Width = 65, ;
		Cancel = .T., ;
		Caption = "Cancel", ;
		TabIndex = 3, ;
		ToolTipText = "Click to Cancel", ;
		Name = "cmdCancel"


	ADD OBJECT cmdsort AS commandbutton WITH ;
		Top = 274, ;
		Left = 9, ;
		Height = 25, ;
		Width = 132, ;
		Cancel = .F., ;
		Caption = "Sort By Form Number", ;
		TabIndex = 3, ;
		TabStop = .F., ;
		ToolTipText = "Click to Change Sort Order", ;
		Name = "cmdSort"


	ADD OBJECT label1 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Form Name", ;
		Height = 17, ;
		Left = 12, ;
		Top = 2, ;
		Width = 132, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Form Number", ;
		Height = 17, ;
		Left = 295, ;
		Top = 2, ;
		Width = 132, ;
		Name = "Label2"


	PROCEDURE Init
		IF TYPE('hdir')="U"
			PUBLIC hdir
		ENDIF
		hdir = SYS(2003)
		IF RIGHT(hdir,1)<>"\"
			hdir = hdir + "\"
		ENDIF
		SET SAFETY OFF
		CREATE TABLE (hdir+"acordfrm.dbf") (formname n(10,0), desc c(50), proc c(50))
		SELE acordfrm
		INDEX ON desc TAG desc
		INDEX ON formname TAG formname
		INSERT INTO acordfrm VALUES (125,'Certificate','Proc 1')
		InsERT INTO acordfrm VALUES (50, 'Form 50','Proc 2')
		INSERT INTO acordfrm VALUES (25, 'Certificate 25','Proc 3')
		INSERT INTO acordfrm VALUES (126,'Form 126','Proc 4')
		INSERT INTO acordfrm VALUES (1,'Form 1','Proc 5')
		INSERT INTO acordfrm VALUES (12,'Form 12','Proc 6')
		DODEFAULT()
		THISFORM.sortorder = TAG()

		sele 0
		CREATE TABLE (hdir+'tacord.dbf') (cnum c(10), descript c(100), proc c(50), nid n(10,0))
		SELE tacord
		USE (hdir+'tacord.dbf') EXCLU
		SELE tacord
		INDEX ON VAL(cnum) TAG valform
		SELE acordfrm
		SET ORDER TO TAG formname
		GO TOP
		SCAN
			SELE tacord
			APPEND BLANK
			REPLACE tacord.cnum WITH STR(acordfrm.formname)
			REPLACE tacord.descript WITH acordfrm.desc
			newid = acordfrm.formname
			REPLACE tacord.nid WITH newid
			REPLACE tacord.proc WITH acordfrm.proc
			SELE acordfrm
		ENDSCAN

		SELE acordfrm
		SET ORDER TO TAG DESC
		GO TOP

		thisform.list1.rowsourcetype = 6
		THISFORM.LIST1.ROWSOURCE='acordfrm.DESC,formname'
		THISFORM.LIST1.COLUMNWIDTHS = '300,130'
		THISFORM.LIST1.REQUERY()
		THIS.CAPTION = "Sort By Form Number"
		THISFORM.LABEL2.LEFT = 295
		Thisform.label2.caption = 'Form Number'
		THISFORM.Label1.caption = "Form Name"

		THISFORM.list1.listindex = 1
		thisform.list1.setfocus()
		thisform.list1.click()
	ENDPROC


	PROCEDURE QueryUnload
		SELE acordfrm
		IF !EMPTY(thisform.sortorder)
			acordorder = thisform.sortorder
			SET ORDER TO TAG &acordorder
		ENDIF
		THISFORM.LIST1.ROWSOURCE='acordfrm.DESC,formname'
		THISFORM.LIST1.COLUMNWIDTHS = '300,130'
		THISFORM.LIST1.REQUERY()
		THIS.CAPTION = "Sort By Form Number"
		THISFORM.LABEL2.LEFT = 295
		Thisform.label2.caption = 'Form Number'
		THISFORM.Label1.caption = "Form Name"
		IF USED('TACORD')
			USE IN TACORD
		ENDIF
		IF FILE(hdir+"tacord.dbf")
			DELETE FILE (hdir+"tacord.dbf")
		ENDIF
		DODEFAULT()
		RETURN .T.
	ENDPROC


	PROCEDURE list1.DblClick
		DODEFAULT()
		THISFORM.cmdOK.click
	ENDPROC


	PROCEDURE list1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		IF LASTKEY() = 13 .or. LASTKEY() = -9
			nKeyCode = 13
			nShiftAltCtrl = 0
		ENDIF

		IF nKeyCode = 13 .or. nkeyCode = -9 
			THISFORM.cmdOK.click
		ELSE
			DODEFAULT()
		ENDIF
	ENDPROC


	PROCEDURE cmdok.Click

		IF ALIAS()="TACORD"
			formchoice = tacord.proc
		ELSE
			formchoice = acordfrm.proc
		ENDIF

		WAIT WINDOW formchoice

		IF THISFORM.QUERYUNLOAD()
			thisform.Release
		ENDIF
	ENDPROC


	PROCEDURE cmdcancel.Click
		IF THISFORM.QUERYUNLOAD()
			thisform.Release
		ENDIF
	ENDPROC


	PROCEDURE cmdsort.Click
		IF TAG()="DESC"
			SELE tacord
			SET ORDER TO TAG valform
			thisform.list1.rowsourcetype = 6
			thisform.list1.rowsource = 'tacord.cnum, descript'
			THISFORM.LIST1.COLUMNWIDTHS = '130,300'
			THISFORM.LIST1.REQUERY()
			THIS.CAPTION = "Sort By Form Name"
			THISFORM.LABEL2.LEFT = 200
			Thisform.label1.caption = 'Form Number'
			THISFORM.Label2.caption = "Form Name"
		ELSE
			SELE acordfrm
			SET ORDER TO TAG DESC
			thisform.list1.rowsourcetype = 6
			THISFORM.LIST1.ROWSOURCE='acordfrm.DESC,formname'
			THISFORM.LIST1.COLUMNWIDTHS = '300,130'
			THISFORM.LIST1.REQUERY()
			THIS.CAPTION = "Sort By Form Number"
			THISFORM.LABEL2.LEFT = 295
			Thisform.label2.caption = 'Form Number'
			THISFORM.Label1.caption = "Form Name"
		ENDIF
		THISFORM.list1.listindex = 1
		thisform.list1.setfocus()
		thisform.list1.click()
	ENDPROC
	PROCEDURE Activate
		THISFORM.List1.SetFocus()
	ENDPROC


ENDDEFINE
.·*´¨)
.·`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
Next
Reply
Map
View

Click here to load this message in the networking platform