with thisform.pageframe1.pagSeatBlocks.grdSeatBlocks .recordsource = "rsTSBlocks" .rowheight = 24 .highlightstyle = 2 * .highlightrowlinewidth = 3 for each loColumn in .columns * loColumn.addproperty("cOriginalControlSource", m.loColumn.controlsource) * loColumn.addproperty("nOriginalWidth", m.loColumn.width) for each loControl in m.loColumn.controls if upper(m.loControl.baseclass) = "HEADER" * loControl.FontSize = 8 bindevent(m.loControl,"Click",thisform,"HeaderClick") *!* loControl.addproperty("CurrentTag","") && Adds CurrentTag property *!* if this.lCreateIndexes && Adds indexes on the fly *!* this.CreateTag (m.loControl) *!* endif endif next next with .colLevels.cboLevels .rowsource = '' .rowsourcetype = 3 .parent.controlsource = 'rsTSBlocks.LevelID' .rowsource = "select * from csrBlockLevels into cursor csrBLvls nofilter" endwith with .colSections.cboSections .rowsource = '' .rowsourcetype = 3 .rowsource = "select * from csrSections into cursor csrSect where LevelID = ?thisform.currentLevelId nofilter" * .parent.controlsource = 'rsTSBlocks.SectionID' .parent.controlsource = [(IIF(seek(rsTSBlocks.SectionId, 'csrSections','SectionId'), csrSections.SDescrip,''))] endwithSo, note the controlsource for the column. In design time this column's property bound set to false and sparse to true (default).
lparameters nColIndex if this.columns[m.nColIndex].name = 'colSections' thisform.currentLevelId = rsTSBlocks.LevelId local lnSectionId lnSectionId = rsTSBlocks.SectionId this.colSections.cboSections.requery() this.colSections.cboSections.value = m.lnSectionId endifAnd this is it, it seems to work well, although I was so exhausted with all my prior unsuccessful attempts that I didn't run too many tests. But it does behave the way I want - it shows correct information as a text in all rows and when I go to that cell, it opens correct list and allows me to select the value. The value is correctly saved in the field.
>*-- 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" >loCombobox.UseAutoFill = .T. >loCombobox.NotEdit = .F. >* >*-- 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" >>
>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.