1

Konu: Örnek: CUSTOM CONTROL DATA BINDING IN A GRID

http://www.foxite.com/archives/0000243334.htm

Visual Fox Pro
* Author: Çetin Başöz.

 
Public oform
oform=Createobject("sampleForm")
oform.Show
 
Define Class sampleForm As Form
  Height = 400
  Width = 300
 
  Add Object myGrid As Grid With ;
    Left = 10, Height = 400, Width = 210, ;
    ColumnCount = 2, RowHeight = 30, DeleteMark=.F.,SplitBar=.F.
 
  Procedure fake
    Lparameters loControl
    loControl.Value = Evaluate(loControl.Parent.ControlSource)
  Endproc
 
  Procedure Load
    Create Cursor DemoCursor (f1 i, f2 i Null)
    For ix = 1 To 10
      Insert Into DemoCursor Values (m.ix, Iif(m.ix%6=0,Null,m.ix%6))
    Endfor
    Locate
  Endproc
 
  Procedure Init
    With This.myGrid
      .Columns(1).Width=55
      .Columns(1).Header1.Caption = 'F1'
 
      With .Columns(2)
        .Header1.Caption = 'F2'
        .Width=100
        .AddObject('myCustom','ButtonControls')
        .CurrentControl = 'myCustom'
        .Sparse = .F.
        .DynamicFontBold = '(thisform.Fake( this.Columns(2).myCustom ))'
        .myCustom.Visible = .T.
      Endwith
    Endwith
  Endproc
Enddefine
 
Define Class buttoncontrols As Container
  Width = 77
  Height = 31
  BackStyle = 0
  BorderWidth = 0
  Value = .Null.
  Name = "buttoncontrols"
  Add Object bit0 As CommandButton With ;
    Left = 0, Height = 27, Width = 25, Caption = "0"
 
  Add Object bit1 As CommandButton With ;
    Left = 25, Height = 27, Width = 25, Caption = "1"
 
  Add Object bit2 As CommandButton With ;
    Left = 50, Height = 27, Width = 25, Caption = "2"
 
  Procedure value_access
    *To do: Modify this routine for the Access method
    Return This.Value
  Endproc
 
  Procedure value_assign
    Lparameters vNewVal
    If Isnull(m.vNewVal)
      This.SetAll('Enabled',.F.)
    Else
      This.bit0.Enabled = Bittest(m.vNewVal,0)
      This.bit1.Enabled = Bittest(m.vNewVal,1)
      This.bit2.Enabled = Bittest(m.vNewVal,2)
    Endif
    This.Value = m.vNewVal
  Endproc
Enddefine
Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü