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: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: RE: Demo: Vertical Scroll Container for Data
Thread ID: 395577 Message ID: 396040 # Views: 67 # Ratings: 5
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Wednesday, January 22, 2014 1:20:17 PM         
   


I would ask the same question that Tom asked (except the BackStyle access part which I never use and prefer using Dynamic* properties instead). Why not grids. Combo and list boxes are very limited compared to grids in ability, capacity and performance. I don't know anything one can't do with grid while doing it with listbox. If you ever read the CHM I added to foxyclasses and check how MoverListXX was born the reason was listbox' terrible performance. With few items listbox is good (read that few 100-200 on some systems and 1000-2000 in another). Here is a grid using a container for example:


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

Define Class myform As Form
  DataSession = 2
  Height = 406
  Width = 485
  Caption = "Sample"

  Add Object grid1 As Grid With ;
    ColumnCount = 1, Height = 406, Panel = 1, ;
    RecordSource = "orders", RowHeight = 96, ScrollBars = 2, ;
    Recordmark=.f., DeleteMark = .f., GridLines=1,;  
    Width = 420, Anchor=7 &&    HeaderHeight = 0, ;

  Procedure grid1.BeforeRowColChange
    Lparameters nColIndex
    Thisform.LockScreen = .T.
  Endproc

  Procedure grid1.AfterRowColChange
    Lparameters nColIndex
    Thisform.LockScreen = .F.
  Endproc

  Procedure Init
    With This.grid1.Columns(1)
      .Width = 420	
      .AddObject('cntOrder','myContainer')
      .cntOrder.Visible = .T.
      .Bound = .F.
      .CurrentControl = "cntOrder"
      .Sparse = .F.
      .cntOrder.Width = .Width
      .Header1.Caption = "Order Info"
      .DynamicBackColor = '(Iif(Recno()%2=0, 0xFFFFFF, 0xE0E0E0))'
    Endwith
  Endproc

  Procedure Load
    Use (_samples+'data\orders') In 0
    Set Multilocks On
    CursorSetProp("Buffering",5,'orders')
  Endproc
Enddefine

Define Class myContainer As Container
  Height = 96
  BackStyle = 0
  BorderWidth = 0

  Add Object lblorder_id As Label With ;
    BackStyle = 0, Caption = "Order_id", Left = 8, Top = 8, Width = 48

  Add Object txtorder_id As TextBox With ;
    ControlSource = "orders.order_id", Left = 78, Top = 8, Width = 55, ;
    Enabled=.F., Fontbold=.T.

  Add Object lblcust_id As Label With ;
    BackStyle = 0, Caption = "Cust_id", Left = 8, Top = 36, Width = 43

  Add Object txtcust_id As TextBox With ;
    ControlSource = "orders.cust_id", Left = 78, Top = 36, Width = 55

  Add Object lblorder_date As Label With ;
    BackStyle = 0, Caption = "Order_date", Left = 8, Top = 64, Width = 62

  Add Object txtorder_date As TextBox With ;
    ControlSource = "orders.order_date", Left = 78, Top = 64, Width = 73

  Add Object combo1 As ComboBox With ;
    BoundColumn = 3, ;
    BoundTo = .T.,;
    ColumnCount = 3, ;
    ColumnWidths = "60,100,40", ;
    RowSourceType = 3, ;
    RowSource = "select first_name,last_name,emp_id from employee into cursor crsEmployee", ;
    ControlSource = "Orders.Emp_id", ;
    FirstElement = 1, ;
    Height = 24, ;
    Left = 186, ;
    NumberOfElements = 0, ;
    Style = 2, ;
    Top = 8, ;
    Width = 180
     
  Add Object command1 As CommandButton With ;
    Top = 44, Left = 234, Width = 84, Caption = "Show customer"
    
  Procedure command1.Click
    Select * From testdata!customer Where cust_id = orders.cust_id
  Endproc
Enddefine


Yet another with a live bar gauge:

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

Define Class myForm As Form
  Add Object myGrid As Grid

  Procedure Load
    Create Cursor myProcess (percent i, Name c(10))
    Rand(-1)
    For ix = 1 To 100
      Insert Into myProcess Values (Int(Rand()*100),Sys(2015))
    Endfor
    Locate
  Endproc

  Procedure Init
    With This.myGrid
      .AddColumn(.ColumnCount+1)
      .Columns(.ColumnCount).ControlSource = 'myProcess.Percent'
      .Columns(.ColumnCount).DynamicFontBold = "!(thisform.UpdateContainer(this.columns(1).myPercent))"
      .Columns(.ColumnCount).Header1.Caption = 'Percentage'
    Endwith

    With This.myGrid.Columns(1)
      .AddObject('myPercent','myContainer')
      .myPercent.Width = .Width
      .myPercent.lblPercent.Width = .Width
      .myPercent.Visible = .T.
      .DynamicFontBold = "thisform.UpdateContainer(this.columns(1).myPercent)"
      .CurrentControl = 'myPercent'
      .Sparse = .F.
    Endwith

    This.myGrid.Columns(1).Enabled = .F.
  Endproc

  Procedure UpdateContainer(toContainer)
    With toContainer
      .shpPercent.BackColor = Iif(percent>90,0xFF,Iif(percent>70,0x00FFFF,0x00FF00))
      .shpPercent.Width = toContainer.Parent.Width * percent/100
      .lblPercent.Caption = '%'+Ltrim(Str(percent))
    Endwith
  Endproc
Enddefine

Define Class myContainer As Container
  BackColor=0xFFFFFF
  BorderWidth=0
  Add Object shpPercent As Shape With BorderStyle = 0
  Add Object lblPercent As Label With Alignment = 2 ,BackStyle=0
Enddefine


VFP grids are not mind blowing right, but still much more capable than VFP listboxes IMHO. Understanding and using them at full potential is next to impossible though (I still learn something about them although I have been a fan of grids since FoxPro - browse there).



Cetin Basoz

Give some sample data in code for your question - here is the tool you need to generate the code

My Blog


MongoDb Certified Developer
MongoDb Certified DBA


Support Wikipedia

ENTIRE THREAD

Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/15/2014 11:48:58 PM
RE: Demo: Vertical Scroll Container for Data Posted by Jun Tangunan @ 1/16/2014 11:36:17 PM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/17/2014 3:18:30 AM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/17/2014 3:18:25 AM
RE: Demo: Vertical Scroll Container for Data Posted by tom knauf @ 1/21/2014 4:54:57 PM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/22/2014 4:02:15 AM
RE: Demo: Vertical Scroll Container for Data Posted by tom knauf @ 1/22/2014 10:53:16 AM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/22/2014 2:18:55 PM
RE: Demo: Vertical Scroll Container for Data Posted by Cetin Basoz @ 1/22/2014 1:20:17 PM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/22/2014 2:20:01 PM
RE: Demo: Vertical Scroll Container for Data Posted by Aldrin Austria @ 1/24/2014 9:44:37 PM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/25/2014 2:07:55 AM
RE: Demo: Vertical Scroll Container for Data Posted by Dan Baker @ 1/23/2014 3:09:09 PM