>I'll add a checkbox as a grid column's controlsource during the grid's init() using this code:
>
>With This.grcPrice
> .addobject("chkPrice","checkbox")
> .sparse=.f.
> .currentcontrol="chkPrice"
> .chkPrice.caption=""
> .visible=.t.
>Endwith
>
>I was wondering why the checkbox is visible, but readonly, when I don't include the ".visible=.t." code. I know that VFP hides controls added with ADDOBJECT(), but why is it visible if I leave that command out? Shouldn't the box not even show up?
Michael,
If the grid's RecordSource has already been assigned, all the columns already have a have current control. You might try using RemoveObject("Text1") to remove the default text box prior to calling add object to add the check box. Also, I'd subclass the checkbox to save on the additional overhead of having to remove the textbox. (I won't have to set the caption and the visible properties). What I do (I'm emulating a browse here) is:
lnlast = FCOUNT()
lcalias = ALIAS() + "."
FOR lni = 1 TO lnlast
lcfield = lcalias + FIELD(lni)
IF VARTYPE(&lcfield) = "L"
locol = EVALUATE("This.Column" + TRANSFORM(lni))
locol.RemoveObject("Text1")
locol.AddObject("GridCk1", "GridCk")
locol.Sparse = .F.
ENDIF
NEXT
and have no problems with the visibility.
George
Ubi caritas et amor, deus ibi est