>Hi Cetin,
>
>>
In VFP8 you can set memberclass for header. Code your own header and set it as memberclass>
>Can't I use the "default" header that comes when I create the grid? I was trying to use it the simplest way I could, without adding any other controls.
>
>Please see the code I CCed you to see if this could be implemented there.
>
>Thanks!
>
>Fernando
Fernando,
Found the code and touched a bit :
Close DataBases All
Use Home () + "Samples\Data\employee.dbf" In 0 Alias MyRecordSource
oGridTest = CreateObject ("frmGridTest")
oGridTest.Show ()
Clear Events
Close DataBases All
Define Class frmGridTest as cPtrForm
Height = 315
Width = 560
Name = "frmGridTest"
Caption = " Grid Tests"
Add Object grdTestGrid as cPtrGrid with Top = 5 , ;
Left = 5 , ;
Height = 275 , ;
Width = 550 , ;
RecordSourceType = 1 , ;
RecordSource = "MyRecordSource"
Add Object cmdCancel as cPtrButton with Top = 285 , ;
Left = 480 , ;
Cancel = .T. , ;
Caption = "\<Close"
Procedure cmdCancel.Click
ThisForm.Release
EndProc
Procedure QueryUnload
ThisForm.cmdCancel.Click
NoDefault
Return .T.
EndProc
PROCEDURE init
this.grdTestGrid.SetSource("MyRecordSource")
endproc
EndDefine
Define Class cPtrGrid as Grid
Top = 0
Left = 0
Height = 100
Width = 100
RowHeight = 17
FontName = "arial"
FontSize = 8
GridLines = 0
DeleteMark = .F.
RecordMark = .T.
AllowCellSelection = .F.
AllowAutoColumnFit = 0
HighlightStyle = 2
HighlightForeColor = RGB (255, 255, 255)
HighlightBackColor = RGB ( 0, 0, 128)
ReadOnly = .T.
Visible = .T.
Procedure AddColumn
Lparameters nIndex, cAlias, cField, cCaption
Nodefault
This.AddObject("clm"+cField,"myColumn", cAlias+"."+cField,nIndex)
Endproc
Procedure SetSource
Lparameters tcRecordsource
With This
.RecordSource = ''
.RecordSource = tcRecordsource
.ColumnCount = -1
For ix = 1 To Fcount(tcRecordsource)
.AddColumn(ix, tcRecordsource,Field(ix,tcRecordsource))
Endfor
.SetAll('Visible',.T.)
Endwith
Endproc
Enddefine
Define Class cPtrButton as CommandButton
Top = 0
Left = 0
Height = 25
Width = 75
Enabled = .T.
Visible = .T.
Style = 0
FontName = "Arial"
FontSize = 8
EndDefine
Define Class cPtrForm as Form
AutoCenter = .T.
ShowWindow = 0
BorderStyle = 2
Enabled = .T.
AlWaysOnTop = .F.
WindowType = 1
ScaleMode = 3
FontName = "Arial"
FontSize = 8
ENDDEFINE
Define Class myColumn As Column
Procedure Init
Lparameters cControlSource, nIndex
With This
.ControlSource = cControlSource
.ColumnOrder = nIndex
.RemoveObject('Header1')
.AddObject('myHeader','myHeader',Justext(cControlSource))
Endwith
Endproc
ENDDEFINE
Define Class myHeader As Header
Procedure Init
Lparameters tcCaption
This.Caption = PROPER(tcCaption)
Endproc
Procedure Click
MESSAGEBOX('Column'+TRANSFORM(This.parent.ColumnOrder)+' is clicked')
Endproc
Enddefine
Cetin