1

Konu: Problem with grid Header name in FoxyClasses

Cetin:

In creating a form wit LocatorGrid, I call headers "Header1". It works. However, when I click right-arrow to move from one column to the next, I get the following error message:

Program Error: Unknown member MYHEADER1.

The error occurs in "afterrowcolchange" in this line:

.myHeader1,caption = myTextBox.tag


If I call "Header1" in my code "myHeader1", I get an error.

Kindly advise.

Hans L

2

Re: Problem with grid Header name in FoxyClasses

Hans,
I couldn't understand it clearly. In LocatorGrid headers are replaced with a custom header class and named MyHeader1.

3

Re: Problem with grid Header name in FoxyClasses

Thanks for your reply, Cetin. Let me be more explicit.

In my form's Init, I have

Visual Fox Pro
THISFORM.set_up_list()


In the form's custom method set_up_list, I have

Visual Fox Pro
WITH THISFORM.grdLocgrid

 
     .Height = 300
     .Top = 20
     .Visible = .T.
     .lKeepFormat = .T.       
     .ColumnCount = 4
 
    .Columns(1).Header1.Caption = 'Name'
    .Columns(1).Width = 500
    .Columns(2).Header1.Caption = 'Entity'
    .Columns(2).Width = 200
    .Columns(3).Header1.Caption = 'Subject'
    .Columns(3).Width = 200
    .Columns(4).Header1.Caption = '# of languages'
    .Columns(4).Width = 200
 
    .SetAll('Fontbold', .T., 'Header')
    .SetAll('Alignment', 2, 'Header')
 
    .Width = .Columns(1).Width + .Columns(2).Width + .Columns(3).Width + .Columns(4).Width
    .Left = .Parent.Left + (.Parent.Width - .Width)/2
 
ENDWITH

It all works. However, when I run the program, and I am in the grid, and I move from one column to the next (by using the right arrow key), I get the error

Program Error: Unknown member MYHEADER1.

Hope this clarifies the issue.

Regards,

Hans

4

Re: Problem with grid Header name in FoxyClasses

I see. Follow that with:

Visual Fox Pro
THISFORM.grdLocgrid.Init()

5

Re: Problem with grid Header name in FoxyClasses

I certainly will. I assume that you mean

Form's Init method:

THISFORM.set_up_list()

THISFORM.grdLocgrid.Init()

Regards,

Hans L

6

Re: Problem with grid Header name in FoxyClasses

Cetin, doing this ...

Form's Init method:

Visual Fox Pro
THISFORM.set_up_list()

 
THISFORM.grdLocgrid.Init()


... made no difference.

I think I recall that you said somewhere that Header1 changes name to Myheader1. In my case, that does not seem to be the case.

If I want to set header names in code, and do setall() for bold, for instance, where should I put this code in order to avoid the "myheader1" error message I get above?

Regards,

Hans L

7

Re: Problem with grid Header name in FoxyClasses

As a matter of fact, I tested by not doing this at all ...

Visual Fox Pro
.Columns(1).Header1.Caption = 'Name'

 
    .Columns(1).Width = 500
    .Columns(2).Header1.Caption = 'Entity'
    .Columns(2).Width = 200
    .Columns(3).Header1.Caption = 'Subject'
    .Columns(3).Width = 200
    .Columns(4).Header1.Caption = '# of languages'
    .Columns(4).Width = 200
 
    .SetAll('Fontbold', .T., 'Header')
    .SetAll('Alignment', 2, 'Header')
 
    .Width = .Columns(1).Width + .Columns(2).Width + .Columns(3).Width + .Columns(4).Width
    .Left = .Parent.Left + (.Parent.Width - .Width)/2


and I still got the Myheader1 error.

Hans L

8

Re: Problem with grid Header name in FoxyClasses

Hans L yazdı:

As a matter of fact, I tested by not doing this at all ...

Visual Fox Pro
.Columns(1).Header1.Caption = 'Name'

 
    .Columns(1).Width = 500
    .Columns(2).Header1.Caption = 'Entity'
    .Columns(2).Width = 200
    .Columns(3).Header1.Caption = 'Subject'
    .Columns(3).Width = 200
    .Columns(4).Header1.Caption = '# of languages'
    .Columns(4).Width = 200
 
    .SetAll('Fontbold', .T., 'Header')
    .SetAll('Alignment', 2, 'Header')
 
    .Width = .Columns(1).Width + .Columns(2).Width + .Columns(3).Width + .Columns(4).Width
    .Left = .Parent.Left + (.Parent.Width - .Width)/2


and I still got the Myheader1 error.

Hans L


try

Visual Fox Pro
.SetAll('Fontbold', .T., 'MyHeader1')

    .SetAll('Alignment', 2, 'MyHeader1')

instead of

Visual Fox Pro
.SetAll('Fontbold', .T., 'Header')

    .SetAll('Alignment', 2, 'Header')

here is my usage customized settings codes @locatorGrid # Init

Visual Fox Pro
Lparameters cSQL, cOrgSource

Thisform.LockScreen=.T.
With This
    .cCurRecForeColor = Rgb(255,0,0) &&Rgb(128,0,64)
    DoDefault(.cSQL)
    .SetAll("DynamicBackColor","IIF(MOD(RECNO( ),2)=0,RGB(255,255,255),RGB(231,231,231))","Column")
    .SetAll("DynamicFontBold", "RecNo(.RecordSource) = .nCurRec", "Column")
    For Each oColumn In .Columns
        oColumn.myHeader1.FontBold=.T.
        oColumn.myHeader1.FontName=[Tahoma]
        oColumn.myHeader1.FontSize=8
        oColumn.myHeader1.Alignment=2
        .FontName=[Tahoma] &&for each columns
        .FontSize=8
    Endfor
    .Column8.InputMask = [999,999,999.99] &&subtotal
    .column8.SetAll([inputmask],[999,999,999.99])
    .Column10.visible=.f.  &&myguid
    .ScrollBars= 3
Endwith
Thisform.LockScreen=.F.

Hans dont  forget ! that this class removing grid header and adding myheader1 to the locator grid header via myheader.prg @ runtime

HTH

9 Son düzenleyen, cetinbasoz (23.10.2010 14:37:04)

Re: Problem with grid Header name in FoxyClasses

After grid init the name is MyHeader1. Instead of a dependency on name, you could use columns(N).Controls(1) or query the name from a custom method. ie:
* Grid.CustomGetHeaderName

Visual Fox Pro
for each loControl in this.Columns(1).Controls

     if lower( loControl.Baseclass ) == 'header'
        return loControl.Name
    endif
endfor

and use in SetAll

Visual Fox Pro
this.Setall('FontBold', .T., this.CustomGetHeaderName())

and last but not least, you could set the fontbold before init. Header change preserves some of the properties (like font) during replacement.

10

Re: Problem with grid Header name in FoxyClasses

That should take care of my problems. Thank you, Cetin.

Hans L