Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combobox DisplayValue Bug Revisited
Message
De
01/02/2006 18:12:06
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Divers
Thread ID:
01092156
Message ID:
01092648
Vues:
20
>Thanks Fabio,
>
>Having been a developer for over 25 years, it still amazes me how a whole days worth of troubleshooting can be solved by a single line of code!..
>The Universal Thread always comes through!
>
>Now any idea why putting a NODEFAULT in the Click method of combo1 solves the problem?
>
>

Sure. ( Little complex to explain )

First:
this work without woraround because nnumber is a character
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show

DEFINE CLASS form1 AS form

AutoCenter = .T.
nnumber = "0"

ADD OBJECT combo1 AS combobox WITH ;
	BoundColumn = 2;
	,BoundTo = .T.	;
	,ColumnCount = 2, ;
	ColumnWidths = "100,0", ; && BUG 1: Combo doesn't respect 0
	RowSourceType = 1, ;
	RowSource = "One,1,Two,2,Three,3,Four,4", ;
	Left = 24, ;
	Style = 2, ;
	Top = 24 ;
	,ControlSource = "THISFORM.nNumber"


 PROCEDURE combo1.InteractiveChange
 	thisform.themes = .T. && force a Paint
 	CHRSAW(2)
	KEYBOARD '{F4}' PLAIN CLEAR  && BUG2 : when ListIndex > 1, DisplayValue is metastable
 ENDPROC

ENDDEFINE
with numeric,
i found Click's NODEFAULT into a couple of minutes,
but it is not a clean workaround, because it stop the natural combo process.

Click's NODEFAULT stop the VFP update sequence:
- Controlsource is not immediately updated
and Valid isn't fired.

Now thinking a few minutes in more, I have found the true workaround,
of course, always with an only line :)

Explain:
Because the list.column(2) is a text number
and (ControlSource) is a number,
VFP must transform() the column value into a number.
In this transformation there is a bug,
(in reality inside the combo they are still many dozens bugs)
and when it reload, after Valid, ControlSource ( 3 times ! in update cycle )
it is not able to scan the column(2) and found the listindex
and into the When ( Remember: VFP call When into combobox,checkbox,... after valid )
the listindex is 0 !
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show

DEFINE CLASS form1 AS form

AutoCenter = .T.
AllowOutput = .F.

nnumber = 0

ADD OBJECT combo1 AS combobox WITH ;
	BoundColumn = 2;
	,BoundTo = .T.	;
	,ColumnCount = 2, ;
	ColumnWidths = "100,0", ; && BUG 1: Combo doesn't respect 0
	RowSourceType = 1, ;
	RowSource = "One,1,Two,2,Three,3,Four,4", ;
	Left = 24, ;
	Style = 2, ;
	Top = 24 ;
	,ControlSource = "thisform.nNumber"

 PROCEDURE combo1.InteractiveChange
 	thisform.themes = .T. && force a Paint
 	CHRSAW(2)
	KEYBOARD '{F4}' PLAIN CLEAR  && BUG2 : when ListIndex > 1, DisplayValue is metastable
 ENDPROC

 PROCEDURE combo1.valid
 	? PROGRAM(1),"LISTINDEX IS OK",this.listindex
 	
 PROCEDURE combo1.when
	TRY
	 	IF THISFORM.ActiveControl=M.THIS
	 		? PROGRAM(1),"LISTINDEX IS BAD",this.listindex
	 	ENDIF
	CATCH
	ENDTRY
	 	
 PROCEDURE combo1.dropdown
* 	combobox::Refresh  && TRUE WORKAROUND
 ENDPROC
 
ENDDEFINE
Hi
Fabio
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform