Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hide grid column
Message
From
23/02/2005 12:47:30
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
23/02/2005 11:58:07
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows XP
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00989465
Message ID:
00989715
Views:
81
>Can you show me an example.

Well I've a sample ready but was in Turkish. I quickly translated important ones.
FYI:
Miktar: Quantity
Toplam: Total
Fiyat: Price
Public oForm
oForm = Createobject("myForm")
oForm.Show

Define Class myForm As Form
  DataSession = 2
  Top = 0
  Left = 0
  Height = 398
  Width = 426
  DoCreate = .T.
  Caption = "Form1"
  Visible = .T.
  Name = "Form1"


  Add Object txtpid As TextBox With ;
    Comment = "", ;
    ControlSource = "fatparent.pkid", ;
    Height = 23, ;
    Left = 108, ;
    TabIndex = 4, ;
    Top = 12, ;
    Width = 81, ;
    Name = "txtPid"


  Add Object lblpid As Label With ;
    AutoSize = .T., ;
    BackStyle = 0, ;
    Caption = "Pid", ;
    Left = 74, ;
    Top = 18, ;
    TabIndex = 3, ;
    Name = "lblPid"


  Add Object txtparentname As TextBox With ;
    Comment = "", ;
    ControlSource = "fatparent.fatname", ;
    Height = 23, ;
    Left = 106, ;
    TabIndex = 8, ;
    Top = 41, ;
    Width = 132, ;
    Name = "txtParentname"


  Add Object lblparentname As Label With ;
    AutoSize = .T., ;
    BackStyle = 0, ;
    Caption = "Parentname", ;
    Left = 28, ;
    Top = 44, ;
    TabIndex = 7, ;
    Name = "lblParentname"


  Add Object txtmiktar As TextBox With ;
    Alignment = 3, ;
    Value = 0, ;
    Height = 23, ;
    Left = 275, ;
    Top = 336, ;
    Width = 137, ;
    Name = "txtMiktar"


  Add Object txttoplam As TextBox With ;
    Alignment = 3, ;
    Value = 0, ;
    Height = 23, ;
    Left = 275, ;
    Top = 366, ;
    Width = 137, ;
    Name = "txtToplam"


  Add Object label1 As Label With ;
    Caption = "Toplam", ;
    Height = 17, ;
    Left = 227, ;
    Top = 366, ;
    Width = 43, ;
    Name = "Label1"


  Add Object label2 As Label With ;
    Caption = "Miktar", ;
    Height = 17, ;
    Left = 234, ;
    Top = 336, ;
    Width = 36, ;
    Name = "Label2"


  Add Object grid1 As Grid With ;
    ColumnCount = 4, ;
    AllowAddNew = .T., ;
    Height = 253, ;
    Left = 24, ;
    Top = 72, ;
    Width = 389, ;
    Name = "Grid1"



  Add Object commandgroup1 As CommandGroup With ;
    AutoSize = .F., ;
    ButtonCount = 4, ;
    Value = 1, ;
    Height = 37, ;
    Left = 264, ;
    Top = 24, ;
    Width = 144, ;
    Name = "Commandgroup1", ;
    Command1.AutoSize = .F., ;
    Command1.Top = 5, ;
    Command1.Left = 5, ;
    Command1.Height = 27, ;
    Command1.Width = 32, ;
    Command1.Caption = "<<", ;
    Command1.Name = "Command1", ;
    Command2.AutoSize = .F., ;
    Command2.Top = 5, ;
    Command2.Left = 39, ;
    Command2.Height = 27, ;
    Command2.Width = 32, ;
    Command2.Caption = "<", ;
    Command2.Name = "Command2", ;
    Command3.AutoSize = .F., ;
    Command3.Top = 5, ;
    Command3.Left = 73, ;
    Command3.Height = 27, ;
    Command3.Width = 32, ;
    Command3.Caption = ">", ;
    Command3.Name = "Command3", ;
    Command4.AutoSize = .F., ;
    Command4.Top = 5, ;
    Command4.Left = 107, ;
    Command4.Height = 27, ;
    Command4.Width = 32, ;
    Command4.Caption = ">>", ;
    Command4.Name = "Command4"


  Procedure parentchanged
    * Parent degistiginde normal olarak tableupdate() olacak veya revert
    * Boylece select-sql dogru sonuc verecek
    Tableupdate(2,.T.,'FatParent')
    Tableupdate(2,.T.,'FatChild')
    External Array arrToplam
    Select Sum(Fiyat*Miktar), Sum(Miktar) ;
      from FatChild ;
      where ParId = FatParent.PkId ;
      into Array arrToplam
    Thisform.txttoplam.Value = Iif(_Tally=0,0,arrToplam[1,1])
    Thisform.txtmiktar.Value = Iif(_Tally=0,0,arrToplam[1,2])
  Endproc


  Procedure Load
    Set Exclusive Off
    Set Multilocks On
    Set Deleted On
    Rand(-1)
    Create Cursor FatParent (PkId i,FatName c(10))
    Create Cursor FatChild (ParId i,Aciklama c(20), Fiyat i, Miktar i)
    Index On ParId Tag ParId
    For ix = 1 To 20
      lcParName = 'Test'+Padl(ix,3,'0')
      Insert Into FatParent Values (ix,lcParName)
      lnChilds = Int(Rand()*10)+1
      For jx = 1 To lnChilds
        Insert Into FatChild ;
          values ;
          (ix,lcParName+' - Item'+Padl(jx,2,'0'),;
          (Int(Rand()*10)+1)*1000,Int(Rand()*5)+1)
      Endfor
    Endfor
    CursorSetProp('Buffering',5,'FatParent')
    CursorSetProp('Buffering',5,'FatChild')
    Select FatParent
    Go Top
    Set Relation To PkId Into FatChild
  Endproc


  Procedure Init
    With Thisform.grid1
      .RecordSource = 'FatChild'
      .Columns(1).ControlSource = 'FatChild.Aciklama'
      With .Columns(2)
        .ControlSource = 'FatChild.Fiyat'
        .Header1.Caption = "Price"
        .AddObject("myTextbox","myTextBox",;
          "thisform.txtToplam, %%delta%% * FatChild.Miktar" )
        .CurrentControl="myTextbox"
        .myTextBox.Visible = .T.
      Endwith
      With .Columns(3)
        .ControlSource = 'FatChild.Miktar'
        .Header1.Caption = "Quantity"
        .AddObject("myTextbox","myTextBox",;
          "thisform.txtToplam, %%delta%% * FatChild.Fiyat"+;
          ",thisform.txtMiktar, %%delta%%" )
        .CurrentControl="myTextbox"
        .myTextBox.Visible = .T.
      Endwith
      .Columns(3).ControlSource = 'FatChild.Miktar'
      .Columns(4).ControlSource = '(FatChild.Fiyat*FatChild.Miktar)'
      .Columns(4).Header1.Caption = "ExtendedPrice"
    Endwith
    Thisform.parentchanged()
  Endproc


  Procedure grid1.AfterRowColChange
    Lparameters nColIndex
    If Empty(FatChild.ParId)
      Replace ParId With FatParent.PkId In 'FatChild'
    Endif
  Endproc

  Procedure commandgroup1.Valid
    Select FatParent
    Do Case
      Case This.Value = 1
        Go Top
      Case This.Value = 2
        Skip -1
        If Bof()
          Go Top
        Endif
      Case This.Value = 3
        Skip
        If Eof()
          Go Bottom
        Endif
      Case This.Value = 4
        Go Bottom
    Endcase
    Thisform.parentchanged()
    Thisform.Refresh
  Endproc
Enddefine

Define Class myTextBox As TextBox
  Calculation = ""

  Procedure Init
    Lparameters tcCalculationPairs
    This.Calculation = m.tcCalculationPairs
  Endproc

  Procedure GotFocus
    This.Tag = Transform(This.Value)
  Endproc

  Procedure LostFocus
    Local lnDelta,ix
    Local Array aCalculation[1]
    lnDelta = Evaluate(This.ControlSource) - Val(This.Tag)
    For ix=1 To Alines(aCalculation,This.Calculation,.T.,',')-1 Step 2
      With Evaluate(aCalculation[m.ix])
        .Value = .Value + ;
          Evaluate( Stuff(aCalculation[m.ix+1],;
          Atc('%%delta%%',aCalculation[m.ix+1]),Len('%%delta%%'),'m.lnDelta') )
      Endwith
    Endfor
  Endproc
Enddefine
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