Glad it worked out.
>Thanks for the response, I tried removing the column without any reference to it in place.. but It's still "there" in debugger. When you say the column is removed, do you mean if you look at Thisform.oGrid properties (at runtime), you can see
>Column1, 3,4,5 ie Column 2 is completely missing?
>
>I am already stepping backwards through the grid so I don't get the out of range error you mention.
>
>I have managed to find a way to detect if the object has already been removed using the Columns[] collection, so that has solved my problem in a round about kind of way, but it's not as clean as I would have hoped
>
>Thanks for the help
>
>Will
>
>>>I suppose what's confusing me is the fact the column doesn't really get removed properly..
>>
>>I remove columns all the time in my one and only grid which gets built on the fly in code in about 35 differnt manifestations. I just tested the code, and indeed the column is removed.
>>
>>>Out of interest, if I have a With..Endwith reference to the column then try and removeObject the column, will that hang onto the reference?
>>
>>Yes. You do not want the column object "selected" when you try to remove it. Trying to remove any object from its container from within the object to be removed may cause the object to "hang".
>>
>>Try something like this from within a grid method....
>>
>>
WITH this
>> FOR lnI = .ColumnCount TO 1 STEP -1
>> IF .Columns[ lnI ] [meets removal condition]
>> .RemoveObject( .Columns[ lnI ].Name )
>> ENDIF
>> NEXT
>>ENDWITH
>>
>>
>>By stepping backward from .ColumnCount, removing columns avoids the nasty out of range index error because lnI can never be greater than the new ColumnCount.
>>
>>Regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.comNo trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.