>Public oForm >oForm = Createobject('comboSample') >oForm.Show > >Define Class comboSample As Form > Top = 0 > Left = 0 > Height = 350 > Width = 620 > DataSession=2 > > Add Object grdItems As Grid With ; > Height = 300, ; > Left = 10, ; > Top = 10, ; > Width = 600, ; > Rowheight = 19,; > RecordSource = "crsItems" > > Procedure Load > Set Fixed On > Set Point To "," > > Select Cast(.Null. As Int) As ProductID, Cast('' As c(50)) As prod_name ; > FROM (_samples+'Data\products') ; > UNION ; > select Int(Val(product_id)) As ProductID,prod_name ; > FROM (_samples+'Data\products') ; > INTO Cursor crsProducts ; > readwrite > Index On ProductID Tag ProductID > > Create Cursor crsItems ; > (LINE_NO i, ORDER_ID c(6), ; > ProductID i Null, UNIT_PRICE Y, QUANTITY i) > > Insert Into crsItems ; > Select LINE_NO, ORDER_ID, ; > Val(product_id) As ProductID, ; > UNIT_PRICE, QUANTITY ; > From (_samples+'data\orditems') > Locate > > Use In 'products' > Use In 'orditems' > > Endproc > > Procedure grdItems.Init > Local ix > With This > For ix = 1 To .ColumnCount > If Upper(Justext(.Columns(m.ix).ControlSource)) == 'PRODUCTID' > With .Columns(m.ix) > .Bound = .F. > .ControlSource = "(Iif(Seek(crsItems.productid,"+; > "'crsProducts','productID'),crsProducts.prod_name,''))" > .Width = 180 > .Alignment = 0 > .AddObject('comboincol','mycombo') > With .ComboIncol > .BoundColumn = 2 > .BoundTo = .T. > .ColumnCount = 2 > .ColumnWidths = "180,100" > .RowSourceType = 3 > .RowSource = "select prod_name,productID"+; > " from crsProducts"+; > " order by 1" +; > " into cursor crsComboSource" > .SpecialEffect = 1 > .Style = 2 > .ControlSource = "crsItems.productID" > .Visible = .T. > Endwith > .CurrentControl = 'comboincol' > Endwith > Exit > Endif > Endfor > .AddColumn(.ColumnCount+1) > .Columns(.ColumnCount).Name = 'showProdID' > .ShowProdID.ControlSource = '(crsItems.ProductID)' > Endwith > Endproc > >Enddefine > >Define Class myCombo As ComboBox > setFixed = '' > Procedure init > This.setFixed = Set('fixed') > endproc > Procedure when > Set Fixed Off > Endproc > > Procedure LostFocus > Local cfixed > cfixed = This.setFixed > Set Fixed &cfixed > Endproc >EnddefineCetin