If at all possible minimize the use of macros. Doing so GREATLY increase processing time. Try something like...
This.grdPatCells.ColumnCount= fcount('PATFILE')
This.grdPatCells.FontBold=.F.
This.grdPatCells.FontName='FIXEDSYS'
This.grdPatCells.FontSize=6
for x=1 to This.grdPatCells.ColumnCount
oPatCol='This.grdPatCells.Column'+allt(str(x))
with (oPatCol)
.Width=40
.Header1.Caption=field(x)
.AddObject("txtDuty"+allt(str(x)),"PatCell")
.CurrentControl="txtDuty"+allt(str(x))
.RemoveObject("Text1")
.ControlSource=field(x)
endwith
next
I am not sure if the evaluation parens work with the WITH...ENDWITH command since I have not used it before with the command, but I assume that you get the 'gist.
//:^)
p.s. Let me know if it does or doesn't work
>
>Hi Larry & David,
>
>I got rid of that problem by placing the table opening code in the calling form.
>However I now have a different problem: The cells which are based on a custom class based on the textbox class blank out when selected.
>The reason for programatically setting up the columns was to be able to use this class and attach Right-click/Validation to the cells.
>The custom class is, at this time, a textbox with its max width set to 4.
>
>
> This.grdPatCells.ColumnCount= fcount('PATFILE')
> This.grdPatCells.FontBold=.F.
> This.grdPatCells.FontName='FIXEDSYS'
> This.grdPatCells.FontSize=6
> for x=1 to This.grdPatCells.ColumnCount
> oPatCol='This.grdPatCells.Column'+allt(str(x))
> &oPatCol..Width=40
> &oPatCol..Header1.Caption=field(x)
> &oPatCol..AddObject("txtDuty"+allt(str(x)),"PatCell")
> &oPatCol..CurrentControl="txtDuty"+allt(str(x))
> &oPatCol..RemoveObject("Text1")
> &oPatCol..ControlSource=field(x)
> next
>
>Thanks for your responses, any suggestions would be appreciated.
>
>
>
>>>Help!
>>>I am having problems designing a grid whose Column Count/ControlSource I programatically set in the Init of the form within a for/next loop for the number of fields.
>>>All seems to work except all the rows have the same values as the first record. The number of rows is correct for the record count.
>>>TIA
>>It would help if you showed how you are coding it...
>>//:^)