>Hi all,
>
>I am having a problem with changing a grid-header. Until now I did it just the way it is described in FAQ 7967 and the grid is part of a regular form.
>Now I have put this form into a class and fox says 'Header1 cannot be created'. It seems, that the original Header1 is not removed correctly anymore.
>
>What's wrong?
>
>
>This is the code I am using:
>
>* code of grid1.init
>with this
> for liZaehler = 1 to .columncount
> for liZaehlHilf = 1 to .columns(liZaehler).controlcount
> if inlist(lower(.columns(liZaehler).controls(liZaehlHilf).class),'header','cheader')
> lcCaption = .columns(liZaehler).controls(liZaehlHilf).caption
> lcHeaderName = alltrim(.columns(liZaehler).controls(liZaehlHilf).name)
> endif
> endfor
> if pemstatus(.columns(liZaehler),lcHeaderName,5)
> .columns(liZaehler).removeobject(lcHeaderName)
> .columns(liZaehler).addobject(lcHeaderName,'cHeader')
> .columns(liZaehler).&lcHeaderName..caption = lcCaption
> .columns(liZaehler).&lcHeaderName..name = lcHeaderName
> endif
> endfor
>endwith
>
>* code of m_class.prg used with 'set procedure to m_class additive'
>define class cheader as header
> name = 'cHeader'
> proc DblClick
> this.parent.parent.header_click(this)
> endproc
> proc RightClick
> this.parent.parent.header_rightclick(this)
> endproc
>ENDDEFINE
I don't know what FAQ says but it's simple :
with oCol
.AddObject("MyHeader","myHeaderClass")
endwith
You don't even need to removeobject('Header1') since a column could only have one header.
Cetin