John:
Here is some code from the Init() of a Grid that works for me in a production program (VFP6, SP5); the only difference I see is the 'Addobject' and 'Sparse' property setting. Check out Column 1 below:
Grid.INIT()
WITH THIS
.RecordSource = "reffhist"
.Column1.ControlSource = "Reffhist.ReferredTo"
.Column1.Sparse = .F.
.Column1.AddObject("ReffTo","combobox")
.Column1.CurrentControl = "ReffTo"
.Column1.Width = 220
.Column1.ReffTo.Rowsource = "ReferredTo"
.Column1.ReffTo.RowSourceType = 2
.Column1.ReffTo.Visible = .T.
.Column2.ColumnOrder=5
.Column3.Width = 63
.Column4.Width = 87
.Column4.BackColor = RGB(192,192,192)
.Column4.Enabled = .F.
.Column5.ColumnOrder = 1
.Column5.Width = 25
.Column5.Alignment = 0
.Column5.BackColor = RGB(192,192,192)
.Column5.Enabled = .F.
.Column5.Visible = .T.
.Column5.Header1.Caption = "SEQ"
ENDWITH
HTH,
-Irv.
>Hi guys:
>
>Still having trouble getting this thing to work. I have downloaded microsofts example of "How to make a combo lookup in a grid" - it doesn't work.
>
>I have played with all of the properties until I am cross-eyed. I need an example of real code that mplements a lookup in a grid. Has anyone done this?
>
>Here are the particulars again.
>2 Tables CurGrid1 - holds the information for display in the grid.
> Driver - holds the drivers information keyed to driverid C(10)
>
>
>WITH .grid
> .column4.controlsource = 'curGrid1.drv_sname'
> WITH .column4
> WITH .cboDriver
> .ControlSource = 'curGrid1.driverid'
> .Columns = 2
> .ColumnWidth = 50,0
> .RowSource = 'driver.drv_sname,driverid'
> .RowSourceType = 6
> ENDWITH
> ENDWITH
>ENDWITH
>
>
>When the grid displays, the column shows all of the driver's shortnames. When I select a row, the combobox shows a dropdown list of driver's shortnames. When I select an item, the display chnages to show the new driver's shortname, but when I leave the row, it reverts to the original driver's name. Looking at the table, I found that it was writing, the driver's short name to the table instead of the driverid.
>
>Please help... I've wasted tons of time on this already.