* bldColSwap.prg >>Lparameters og As Grid, nCol1, nCol2 >>*[2005/05/09 14:01:59] ndragan - pass a reference to the grid and >>* the numbers of columns to swap >>*[2009/07/07 14:02:36] ndragan - added "bld" to the name >>Local cName1, cName2 >>og.AddColumn() >>og.Columns[og.ColumnCount].Name="coltemp" >>objclone(og.Columns[nCol1],og.coltemp) >>objclone(og.Columns[nCol2],og.Columns[nCol1]) >>objclone(og.coltemp, og.Columns[nCol2]) >>cName1=og.Columns[nCol1].Name >>cName2=og.Columns[nCol2].Name >>og.Columns[nCol1].Name = Sys(2015) >>og.Columns[nCol2].Name=cName1 >>og.Columns[nCol1].Name=cName2 >>og.RemoveObject("coltemp") >> >>*--------------------------------------------------- >>Procedure objclone(o1 As Column, o2 As Column) >>*-- dn 13/06/04 >> Local c, o, N, i, l, cCRS, aProp[1,1], omember1 As TextBox, omember2 >> >>* reset o2 to default >> N=Amembers(aProp,o2,1,"UC") >> For j=1 To N >> cWhat=aProp[j,2] && what is it - property, method, event, member >> cWhatName=aProp[j,1] && PEM name >> Do Case >> Case cWhat="Property" And Proper(cWhatName)="Name" >>* do nothing, name is handled outside this procedure >> Case Inlist(cWhat, "Property", 'Method' , 'Event') >>* whatever it is, try to remove it, we want the target object to lose personality >> Try >> o2.ResetToDefault(cWhatName) >> Catch >>* do nothing, really >> Endtry >> Case cWhat="Member" >> Try >> o2.RemoveObject(cWhatName) >> Catch >>* do nothing - it can't be removed because it is added at class level >> Endtry >> Endcase >> Endfor >> >>* now copy all from o1 to o2 >>* members first >> N=Amembers(aProp,o1,2) >> For i=1 To N >> omember1=Evaluate("o1."+aProp[i,1]) >> If Type("o2."+aProp[i,1])#"O" >> o2.Newobject(aProp[i,1],omember1.Class, omember1.ClassLibrary) >> Endif >> omember2=Evaluate("o2."+aProp[i,1]) >> objclone(omember1, omember2) >> Endfor >>* and now copy all properties and code >> N=Amembers(aProp,o1,1,"UC") >> >> For j=1 To N >> cWhat=aProp[j,2] && what is it - property, method, event, member >> cWhatName=aProp[j,1] && PEM name >> Do Case >> Case cWhat="Property" And Proper(cWhatName)="Name" >>* do nothing, name is handled outside this procedure >> Case Inlist(cWhat, "Property") >> If PemStatus(o2,cWhatName,5) >> Store Evaluate("o1."+cWhatName) To ("o2."+cWhatName) >> Else >> o2.AddProperty(cWhatName, Evaluate("o1."+cWhatName)) >> Endif >> Case Inlist(cWhat, 'Method' , 'Event') >>* whatever it is, try to convert into a string >> o2.WriteMethod(cWhatName, o1.ReadMethod(cWhatName)) >> Case cWhat="Member" >>* remove it from the source object >> o1.RemoveObject(cWhatName) >> Endcase >> Endfor >>