>I have a grid with a Field Chooser button next to it. When the user
>clicks it, a list of fields, generated from the control sources of
>each grid column, is displayed in a list. The user can add, remove
>or re-arrange the list items. The list is then transfered to an array.
>
>I then want to rebuild the grid using the array. The code I have is:
>
> FOR nColumn = oGrid.ColumnCount TO 1 STEP -1
> oGrid.DeleteColumn(nColumn)
> ENDFOR
>
> oGrid.RecordSource = cRecordSource
>
> FOR nColumn = 1 TO nTotalCols
> cColName = aFldNames[nColumn]
> oGrid.AddColumn(nColumn)
> oGrid.Columns[nColumn].ControlSource = cColName
> oGrid.Columns[nColumn].Header1.Caption = cColName
> oGrid.Columns[nColumn].ReadOnly = .T.
> ENDFOR
>>
>When I put the oGrid.RecordSource line BEFORE the AddColumns loop, I get all
>fields in the table, then the fields I added.
>
>When I put the oGrid.RecordSource line AFTER the AddColumns loop, regardless
>of what I specified as the control source in the loop, the ControlSources are
>always set up first field in the table to last.
>
>What am I doing wrong here?
>
>Thanks
Kevin,
Try adding :
.Columncount = -1
before recordsource assignment.
Cetin