*buildruler.prg aselobj(aSelected) && Creates an array referencing selected objects on form aselobj(aContainer,1) *Creates an array of 1 element referencing *container of selected objects on form oLabel = _getref(@aSelected,"label01") && Find label referencer in array oMajor = _getref(@aSelected),"linemajor01") oMinor = _getref(@aSelected),"lineminor01") lnRulerUnits = 20 && 20 unit ruler lnUnit = 30 && 30 pixels units with aContainer[1] && Parent -form or another type of container for ix = 2 to lnRulerUnits oLabel.CloneObject("Label"+padl(ix,2,"0")) oMajor.CloneObject("LineMajor"+padl(ix,2,"0")) with eval(".Label"+padl(ix,2,"0")) .Left = (ix - 1) * lnUnit + oLabel.left .Caption = padl(ix,2,"0") endwith with eval(".LineMajor"+padl(ix,2,"0")) .Left = (ix - 1) * lnUnit + oMajor.left endwith if ix < lnRulerUnits oMinor.CloneObject("Label"+padl(ix,2,"0")) with eval(".LineMinor"+padl(ix,2,"0")) .Left = (ix - 1) * lnUnit + oMinor.left endwith endif endfor .Setall("Visible",.t.) endwith * This sample also has method code * Assume you're adding controls to grid columns * and want to assign keypress code from already there text1.keypress aselobj(aSelected) && Just assuming grid(s) are selected w/o check for each oGrid in aSelected for each oColumn in oGrid.Columns with oColumn .Addobject("myTextBox","TextBox") .myTextbox.writemethod("KeyPress",.Text1.ReadMethod("KeyPress")) .CurrentControl = "myTextBox" .Sparse = .f. endwith endfor endforCetin