Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: SelStart not work in Column.Editbox when Sparse=.F.
Message
 
À
23/02/2006 11:57:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01098093
Message ID:
01098764
Vues:
14
Fabio,

Your workaround seems not to be a solution to my problem (not your fault). What I want is whenever a user modifies the content of a column, the color of all grid cells change to reflect a "modified" state. Here is the code using your workaround:
o=NewObject("form1")
o.Show(1)

Define Class form1 As Form
	Dirty=.F.
	Width=500
	Height=300
	AllowOutput=.F.
	Add Object Grid1 As MyGrid
	Add Object Label1 As Label With AutoSize=.T.,Top=230;
		, Caption='Try to change "LOne" to "Line".'

	Procedure Load
	Create Cursor Test (f1 m)
	Insert Into Test Values ('Text LOne 1')
	Insert Into Test Values ('Text Line 2')
	Go Top

EndDefine

Define Class MyGrid As Grid
	Height = 200
	RowHeight = 60
	Add Object Column1 As EditColumn
EndDefine

Define Class EditColumn As Column
	Sparse=.F.
	Add Object Header1 As Header
	Add Object Editbox1 As Editbox1
EndDefine

Define Class Editbox1 As EditBox
	SavedSelStart=-1

	Procedure KeyPress
	Lparameters nKeyCode, nShiftAltCtrl

	If !(m.nShiftAltCtrl=1 And Between(m.nKeyCode,49,57)) And (Between(m.nKeyCode,32,255) Or InList(m.nKeyCode,7))
		If !Thisform.Dirty
			This.SavedSelStart=This.SelStart
			This.Parent.BackColor=Rgb(192,255,224)
			Thisform.Dirty=.T.
			This.SelStart=This.SavedSelStart
		EndIf
	EndIf

	Hidden Procedure SelStart_Assign(SelStart)
		Private i
		For i=m.this.SelStart To m.SelStart-1
			EditBox::KeyPress(4,0)
		Next
		For i=m.this.SelStart To m.SelStart+1 Step -1
			EditBox::KeyPress(19,0)
		Next
EndDefine
My workaround works for this simple example and my current project, but failed in a form of another project.

Ben



>this is my solution ( I don't put it in production !)
>
>o=NewObject("form1")
>
>o.Show(1)
>
>Define Class form1 As Form
>	Width=500
>	Height=300
>	Add Object Grid1 As MyGrid
>	Add Object Label1 As Label With AutoSize=.T.,Top=230;
>		, Caption='Press right mouse button to set selstart = 3'
>
>	Procedure Load
>	Create Cursor Test (f1 m)
>	Insert Into Test Values ('Text Line 1')
>	Insert Into Test Values ('Text Line 2')
>	Go Top
>
>EndDefine
>
>Define Class MyGrid As Grid
>	Height = 200
>	RowHeight = 60
>	Add Object Column1 As EditColumn
>EndDefine
>
>Define Class EditColumn As Column
>	Sparse=.F.
>	Add Object Header1 As Header
>	Add Object Editbox1 As Editbox1
>EndDefine
>
>Define Class Editbox1 As EditBox
>	
>	Procedure RightClick
>		This.SelStart = 3
>
>	HIDDEN PROCEDURE SelStart_Assign(SelStart)
>		PRIVATE i
>		FOR i=m.this.SelStart TO m.SelStart-1
>			Editbox::keypress(4,0)
>		NEXT
>		FOR i=m.this.SelStart TO m.SelStart+1 STEP -1
>			Editbox::keypress(19,0)
>		NEXT
>ENDDEFINE
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform