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 EndDefineMy workaround works for this simple example and my current project, but failed in a form of another project.
>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 >