>Push Key Clear >o=NewObject("form1") >o.Show(1) >Pop Key > >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='Push F5 to set _Screen.ActiveForm.Grid1.Column1.Editbox1.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 > SelStartWanted=-1 > SetSel=-1 > > Procedure KeyPress > Lparameters nKeyCode, nShiftAltCtrl > If m.nKeyCode=-4 && Key F5 > This.SelStartWanted=3 > This.SelStart=This.SelStartWanted > EndIf > > Procedure Value_Access > If This.SelStartWanted>=0 > *- Value_Access will run twice. Don't set SelStart in 1st time > If This.SetSel=-1 > This.SetSel=0 > Else > *- Set SelStart in 2nd Value_Access > This.SelStart=This.SelStartWanted > Store -1 To This.SelStartWanted,This.SetSel > EndIf > EndIf > Return This.Value >EndDefine >>
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 HIDDEN SelStartWanted SelStartWanted = NULL Procedure RightClick This.SelStart = 3 HIDDEN Procedure Value_Access DO CASE CASE m.This.SelStartWanted > 0 This.SelStartWanted = - m.This.SelStartWanted CASE m.This.SelStartWanted < 0 This.SelStart_Assign(- m.This.SelStartWanted,.T.) ENDCASE Return m.This.Value HIDDEN PROCEDURE SelStart_Assign(SelStart,lInternal) IF m.lInternal This.SelStartWanted = NULL this.SelStart=m.SelStart RETURN ENDIF STORE m.SelStart TO This.SelStartWanted,This.SelStart ENDDEFINEthis 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