Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create classes from columns & headers And add to
Message
From
30/12/2000 09:31:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/12/2000 04:55:16
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00457692
Message ID:
00458073
Views:
26
>how to create classes from columns & headers And add to grid ?
>I want to add properties to the columns & header as the application will be used in there languages
> the fontnames, fontsize, captions and current language properties are added to each object. The gird
>adds the default header & column class.
>Rajesh

Rajesh,
If you should play with columns and headers which are nonvisual classes then easiest is to use .prg style classes. Below is a sampling (with my laziness on 'clear events') :
on key label 'F2' clear events
use employee
oForm  = createobject('Form')
oForm.Addobject('myGrid','myGrid','employee')
oForm.myGrid.Visible = .t.
oForm.Show
read events

Define class myGrid as grid
  DeleteMark = .F.
  ReadOnly = .T.
  RecordMark = .F.
  ScrollBars = 2
  Name = "grdMyGrid"

  Procedure addcolumn
  Lparameters nIndex, cAlias, cField
  Nodefault
  This.addobject("clm"+cField,"myColumn", cAlias+"."+cField,nIndex)
Endproc

  Procedure init
  Lparameters tcRecordsource
  With this
    .Columncount = -1
    .recordsource = tcRecordsource
    nOldColCount = .columncount
    For ix = 1 to fcount(tcRecordsource)
      .AddColumn(ix, tcRecordsource,field(ix,tcRecordsource))
    Endfor
    For ix = nOldColCount to 1 step -1
      .RemoveObject(.Columns(ix).name)
    Endfor
  Endwith
Endproc
Enddefine

Define class myColumn as column
  Resizable = .F.
  Movable = .F.
  Procedure init
  Lparameters cControlSource, nIndex
  With this
    .controlsource = cControlSource
    .ColumnOrder = nIndex
    .RemoveObject('Header1')
    .Addobject('myHeader','myHeader')
    .AddObject("myText","myGridTxtBox")
    .CurrentControl = "myText"
    .Sparse = .F.
  Endwith
Endproc
  Procedure MouseMove
  Lparameters nButton, nShift, nXCoord, nYCoord
  With this.Parent
    lnActiveRow = ceiling( ;
      ( nYCoord - (.top + .headerheight) ) / .rowheight )
    .ActivateCell(lnActiveRow,3)
  Endwith
  This.setfocus()
  This.myText.Tooltiptext = iif(type(this.controlsource)='C',this.myText.Value,'')

Endproc
Enddefine


Define class myGridTxtBox as TextBox
  BackColor = rgb(0,0,255)
  ForeColor = rgb(255,255,255)
  SelectedBackColor = rgb(255,0,0)
  SelectedForeColor = rgb(255,255,0)
  Name = "Text1"
  Procedure init
  This.BorderStyle = 0
Endproc
  Procedure click
  This.setfocus()
Endproc
Enddefine

Define class myHeader as Header
  BackColor = 0
  ForeColor = rgb(255,255,0)
  Procedure init
  This.Caption = this.parent.controlsource
Endproc
Enddefine
What it demonstrates is how default column, header and textboxes are replaced with custom ones. Beware though this sample assumes there is no grid that you have modified PEM, just gets the recordsourcename and builds its own.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform