Advertisement
willianto

Contoh menggunakan HFlexGrid

Aug 11th, 2017
3,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. * ini bukan bikinan saya
  2. * ini saya co pas dari https://www.foxite.com/archives/grid-0000236901.htm
  3.  
  4. Public oForm
  5. oForm = Createobject('myForm')
  6. oForm.Show
  7.  
  8. Define Class myform As Form
  9.  Height = 350
  10.  Width = 600
  11.  DataSession =2
  12.  
  13.  Add Object hflex As OleControl With ;
  14.   Height = 350, ;
  15.   Width = 600, ;
  16.   Name = "Hflex", ;
  17.   OleClass = 'MSHierarchicalFlexGridLib.MSHFlexGrid'
  18.  
  19.  Procedure Load
  20.   Use (_samples+"data\employee")
  21.  Endproc
  22.  
  23.  Procedure SetFlex
  24.   Select employee
  25.   With This.hflex
  26.    .Rows = Reccount('employee')+2
  27.    .Cols = 6
  28.    .FixedRows = 2
  29.    .FixedCols = 0
  30.    .Mergecells = 3
  31.    For ix = 0 To .Rows-1
  32.     .MergeRow(m.ix) = .T.
  33.    Endfor
  34.    For ix = 0 To .Cols-1
  35.     .MergeCol(m.ix) = .T.
  36.    Endfor
  37.    .FillStyle = 1
  38.    .ColWidth(2,0) = 3000
  39.    .ColWidth(3,0) = 1200
  40.    .Row = 0
  41.    .Col = 0
  42.    .Rowsel = 1
  43.    .Colsel = .Cols-1
  44.    .CellAlignment = 4
  45.  
  46.    .Row = 2
  47.    .Col = 0
  48.    .Rowsel = .Rows-1
  49.    .Colsel = .Cols-1
  50.    .CellAlignment = 1
  51.  
  52.    Store 'Name' To ;
  53.     .TextMatrix(0,0),;
  54.     .TextMatrix(0,1)
  55.    Store 'Address' To ;
  56.     .TextMatrix(0,2),;
  57.     .TextMatrix(0,3),;
  58.     .TextMatrix(0,4),;
  59.     .TextMatrix(0,5)
  60.  
  61.    .TextMatrix(1,0) ='First Name'
  62.    .TextMatrix(1,1) ='Last Name'
  63.    .TextMatrix(1,2) ='Street'
  64.    .TextMatrix(1,3) ='City'
  65.    .TextMatrix(1,4) ='Region'
  66.    .TextMatrix(1,5) ='Country'
  67.  
  68.    Scan
  69.     .TextMatrix(Recno()+1,0) = first_name
  70.     .TextMatrix(Recno()+1,1) = last_name
  71.     .TextMatrix(Recno()+1,2) = address
  72.     .TextMatrix(Recno()+1,3) = city
  73.     .TextMatrix(Recno()+1,4) = Region
  74.     .TextMatrix(Recno()+1,5) = country
  75.  
  76.     .Row = Recno()+1
  77.     .Col = 0
  78.     .Rowsel = .Rows-1
  79.     .Colsel = .Cols-1
  80.     Do Case
  81.      Case country = 'USA'
  82.       .Cellbackcolor = 0xC0FFFF
  83.      Case country = 'UK'
  84.       .Cellbackcolor = 0xFFFFC0
  85.      Case country = 'France'
  86.       .Cellbackcolor = 0xFFC0FF
  87.      Otherwise
  88.       .Cellbackcolor = 0xC0C0C0
  89.     Endcase
  90.    Endscan
  91.   Endwith
  92.  Endproc
  93.  
  94.  Procedure Init
  95.   This.SetFlex()
  96.  Endproc
  97. Enddefi
  98. * ini saya co pas dari https://www.foxite.com/archives/grid-0000236901.htm
  99.  
  100. Public oForm
  101. oForm = Createobject('myForm')
  102. oForm.Show
  103.  
  104. Define Class myform As Form
  105.  Height = 350
  106.  Width = 600
  107.  DataSession =2
  108.  
  109.  Add Object hflex As OleControl With ;
  110.   Height = 350, ;
  111.   Width = 600, ;
  112.   Name = "Hflex", ;
  113.   OleClass = 'MSHierarchicalFlexGridLib.MSHFlexGrid'
  114.  
  115.  Procedure Load
  116.   Use (_samples+"data\employee")
  117.  Endproc
  118.  
  119.  Procedure SetFlex
  120.   Select employee
  121.   With This.hflex
  122.    .Rows = Reccount('employee')+2
  123.    .Cols = 6
  124.    .FixedRows = 2
  125.    .FixedCols = 0
  126.    .Mergecells = 3
  127.    For ix = 0 To .Rows-1
  128.     .MergeRow(m.ix) = .T.
  129.    Endfor
  130.    For ix = 0 To .Cols-1
  131.     .MergeCol(m.ix) = .T.
  132.    Endfor
  133.    .FillStyle = 1
  134.    .ColWidth(2,0) = 3000
  135.    .ColWidth(3,0) = 1200
  136.    .Row = 0
  137.    .Col = 0
  138.    .Rowsel = 1
  139.    .Colsel = .Cols-1
  140.    .CellAlignment = 4
  141.  
  142.    .Row = 2
  143.    .Col = 0
  144.    .Rowsel = .Rows-1
  145.    .Colsel = .Cols-1
  146.    .CellAlignment = 1
  147.  
  148.    Store 'Name' To ;
  149.     .TextMatrix(0,0),;
  150.     .TextMatrix(0,1)
  151.    Store 'Address' To ;
  152.     .TextMatrix(0,2),;
  153.     .TextMatrix(0,3),;
  154.     .TextMatrix(0,4),;
  155.     .TextMatrix(0,5)
  156.  
  157.    .TextMatrix(1,0) ='First Name'
  158.    .TextMatrix(1,1) ='Last Name'
  159.    .TextMatrix(1,2) ='Street'
  160.    .TextMatrix(1,3) ='City'
  161.    .TextMatrix(1,4) ='Region'
  162.    .TextMatrix(1,5) ='Country'
  163.  
  164.    Scan
  165.     .TextMatrix(Recno()+1,0) = first_name
  166.     .TextMatrix(Recno()+1,1) = last_name
  167.     .TextMatrix(Recno()+1,2) = address
  168.     .TextMatrix(Recno()+1,3) = city
  169.     .TextMatrix(Recno()+1,4) = Region
  170.     .TextMatrix(Recno()+1,5) = country
  171.  
  172.     .Row = Recno()+1
  173.     .Col = 0
  174.     .Rowsel = .Rows-1
  175.     .Colsel = .Cols-1
  176.     Do Case
  177.      Case country = 'USA'
  178.       .Cellbackcolor = 0xC0FFFF
  179.      Case country = 'UK'
  180.       .Cellbackcolor = 0xFFFFC0
  181.      Case country = 'France'
  182.       .Cellbackcolor = 0xFFC0FF
  183.      Otherwise
  184.       .Cellbackcolor = 0xC0C0C0
  185.     Endcase
  186.    Endscan
  187.   Endwith
  188.  Endproc
  189.  
  190.  Procedure Init
  191.   This.SetFlex()
  192.  Endproc
  193. Enddefine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement