Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Ovette Abejuela
  Where is Ovette Abejuela?
 Cagayan de Oro City
 Philippines
 Ovette Abejuela
 Tags
Subject: RE: Grid Class(Column,Header,Textbox)
Thread ID: 143312 Message ID: 143316 # Views: 4 # Ratings: 1
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Monday, August 27, 2007 7:38:54 PM         
   


> Hello everyone,
>
> I'm pretty mixed up already on how to implement what i have in mind:
> - I wanted to create a grid class which in it is also a column, header,
> and textbox class
> - Creating a grid class is easy BUT...
> - the hard part is how do i integrate for this grid class to have under
> it a Column,Header and Textbox class
> - in my search and reading and most of them from this wonderful site,
> i was led to BINDEVENT() and/or programatically doing it as such:
> "I got the code below from this site but i will have some changes in it
> if i could make it work with my grid"
>

>
        
>         DEFINE CLASS GridColumn as Column
>          PROCEDURE Init
>           this.AddObject("hdrCol", "hdrColumn")
>           this.AddObject("txtCol", "txtColumn")
>           This.CurrentControl= "TxtCol"
>          ENDPROC
>         ENDDEFINE
> 
>         DEFINE CLASS hdrColumn as Header
>          PROCEDURE click
>           DO ColOptions.Mpr WITH this.parent.Name, this.Parent.columnorder
>          ENDPROC
>         ENDDEFINE
> 
>         DEFINE CLASS txtColumn as textbox
>          PROCEDURE Click
>           DO RecOptions.Mpr WITH this.value
>          ENDPROC
>         ENDDEFINE

> - I really dont know i'f im reading the right stuff, can somebody please
> help me put what i have in mind into an actual class, thanks a lot!


You can removeobject/addobject in grid init, or easier you could override addcolumn method.
However since you're using VFP9 the easiest would be to use MemberClass* properties.
If you do that adding your own textbox, checkbox etc, your header and columns then you woudn't need bindevent and such a grid would even work in VFP5.

Here is a simple one (warning: a rough sample):

Public oForm
oForm  = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  DataSession = 2
  ShowTips = .T.
  Procedure Load
    Use (_samples+'data\employee')
  Endproc
  Add Object myGrd As myGrid With RecordSource = 'Employee'
Enddefine

Define Class myGrid As Grid
  DeleteMark = .F.
  ReadOnly = .T.
  RecordMark = .F.
  ScrollBars = 3
  SplitBar = .F.
  Highlight = .F.
  HighlightRow = .F.

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

  Procedure Init
    Lparameters tcRecordsource
    tcRecordSource = Iif(Empty(m.tcRecordSource),This.RecordSource,m.tcRecordSource)
    With This
      .ColumnCount = -1
      .RecordSource = tcRecordsource
      nOldColCount = .ColumnCount
      For ix = 1 To Fcount(tcRecordsource)
        .AddColumn(ix, tcRecordsource,Field(ix,tcRecordsource))
      Endfor
      .ColumnCount = nOldColCount
      .SetAll('Visible',.T.)
    Endwith
  Endproc
Enddefine

Define Class myColumn As Column
  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
Enddefine


Define Class myGridTxtBox As TextBox
  Procedure Init
    This.BorderStyle = 0
  Endproc
  Procedure Click
    This.SetFocus()
    This.SelStart=0
    this.SelLength = LEN(ALLTRIM(TRANSFORM(this.value)))
  ENDPROC
Enddefine

Define Class myHeader As Header
  Procedure Init
    This.Caption = Proper(Justext(This.Parent.ControlSource))
  ENDPROC
  PROCEDURE Click
  WAIT WINDOW NOWAIT "Subclassed header click at column"+TRANSFORM(this.Parent.ColumnOrder)
  endproc
Enddefine



Cetin Basoz

ENTIRE THREAD

Grid Class(Column,Header,Textbox) Posted by Ovette Abejuela @ 8/27/2007 7:11:38 PM
RE: Grid Class(Column,Header,Textbox) Posted by Cetin Basoz @ 8/27/2007 7:38:54 PM
RE: Grid Class(Column,Header,Textbox) Posted by Ovette Abejuela @ 8/28/2007 7:17:50 AM