*-- Comobobox for reason of absence. loColumn = THIS.Column12 loColumn.ControlSource = "" loColumn.NewObject("ReasonDataEntry","Combobox") * LOCAL loCombobox AS Combobox * loCombobox = loColumn.ReasonDataentry loCombobox.Visible = .T. loCombobox.ColumnCount = 2 loCombobox.BoundColumn = 2 loCombobox.BoundTo = .F. loCombobox.ColumnWidths = "160,0" * *-- Here get the list of records from the table (a regular USE or SELECT statement can be used if you have VFP tables). LOCAL loSReason AS VReasonBiz OF payroll_employees_sickness_reason.vcx loSReason = NEWOBJECT("SReasonBiz","payroll_employees_sickness_reason.vcx") loSReason.OrderFieldName = "srDescr" loSReason.DoGetAllRecords() * *-- Now add the values using AddListItem instead of using the cursor as recordsource makes the combobox *-- behave much more nicely. LOCAL loCounter AS lnCounter OF Utils loCounter = NEWOBJECT("lnCounter","Utils") * loSReason.DoSelect() * SCAN loCounter.DoAdd() loCombobox.AddListItem(loSReason.srDescr,loCounter.Value,1) loCombobox.AddListItem(loSReason.srKey,loCounter.Value,2) ENDSCAN * loColumn.Sparse = .F. loColumn.CurrentControl = "ReasonDataentry" loColumn.ControlSource = THIS.AliasName + ".siSrKey"Now you can add multiple of those comboboxes with different lists and use DynamicCurrentControl() to display them individually in each row based on another field:
loColumn.DynamicCurrentControl = "ICASE(ThisAlias.OtherField=1,'ReasonDataentry',ThisAlias.OtherField=2,'OtherCombo',etc...)"Now after changing the value in the first combo, all you need to do is a Grid.REFRESH() to make the DynamicCurrentControl switch the control for you.