Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple row per record in a grid
Message
From
27/06/2005 05:48:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/06/2005 02:48:59
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Germany
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
Database:
MySQL
Miscellaneous
Thread ID:
01024759
Message ID:
01026640
Views:
28
This message has been marked as the solution to the initial question of the thread.
>Hello Cetin !
>
>Thank you for your hits, but i can't get it running in the way i want ??
>
>My application works with sql_passthrough.
>I define my grid at init of a form
>...
>thisform.grid1.column1.header = ...
>thisform.grid1.column1.width = ...
>thisform.grid1.column1.currentcontrol = mycombo && if i want a combobox instead of the default textbox
>
>thisform.grid1.column2.header = ...
>thisform.grid1.column2.width = ...
>...
>
>
>l_cursor = "mybuffer"
>
>With the values of some searchfields i build a select string
>
>thisform.grid1.recordsource = " "
>l_select = "select a,b,c,d,e,f from ....... where ....."
>sql_execute(connection,l_select,(l_cursor))
>thisform.grid1.recordsource = (l_cursor)
>
>Now i build a containerclass with two textboxes (mydoubletext)
>I put the container in column1.
>At init of my form i do :
>...
>thisform.grid1.recordsource = " "
>Thisform.grid1.column1.currentcontrol = mydoubletext
>thisform.grid1.recordsource = (l_cursor)
>...
>The 2 textboxes in column1 are empty, column2 shows b, column3 shows c ....
>
>I want a + b of each record of mybuffer in the 2 textboxes of column1,c in column2 ....
>
>I tried
>Thisform.grid1.column1.currentcontrol = mydoubletext
>thisform.grid1.column1.controls(1).value = mybuffer.a
>thisform.grid1.column1.controls(2).value = mybuffer.b
>
>but then the 2 textboxes of column1 show a + b of the first record in all rows and column2 shows the different b values,column3 shows the different c values ...
>
>How to put a + b of each record of mybuffer in the 2 textboxes of column1,c in column2,d in column3 .... ??????
>
>Any help welcomed
>Best Regards
>Albert

Albert,
In container too texboxes (or other objects) should have controlsources. If you simply set the value property it'd effect all rows as you saw. ie:

thisform.grid1.column1.controls(1).Controlsource = "myBuffer.a"

Here is a sample showing few fields from orders in a grid using container:
oForm = Createobject('MyForm')
oForm.Show()
Read Events

Define Class myform As Form
  DataSession = 2
  Top = 0
  Left = 0
  Height = 362
  Width = 485
  DoCreate = .T.
  Caption = "Sample"
  Name = "Form1"

  Add Object grid1 As Grid With ;
    ColumnCount = 1, ;
    Height = 310, ;
    Left = 12, ;
    Panel = 1, ;
    RecordSource = "orders", ;
    RowHeight = 96, ;
    ScrollBars = 2, ;
    Top = 12, ;
    Width = 420, ;
    Name = "Grid1"

  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)
      .AddObject('Container1','myContainer')
      .Container1.Visible = .T.
      .Bound = .F.
      .CurrentControl = "Container1"
      .Width = 380
      .Sparse = .F.
      .Header1.Caption = "Order Info"
    Endwith
  Endproc

  Procedure Load
    Use testdata!orders In 0
    Set Multilocks On
    CursorSetProp("Buffering",5,'orders')
  Endproc

  Procedure QueryUnload
    Clear Events
  Endproc
Enddefine

Define Class myContainer As Container
  Width = 380
  Height = 96
  Name = "Container1"

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

  Add Object txtorder_id As TextBox With ;
    ControlSource = "orders.order_id", ;
    Left = 78, ;
    Top = 8, ;
    Width = 55, ;
    Name = "txtOrder_id"

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

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

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

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

  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, ;
    Name = "Combo1"

  Add Object command1 As CommandButton With ;
    Top = 44, ;
    Left = 234, ;
    Width = 84, ;
    Caption = "Show customer", ;
    Name = "Command1"

  Procedure command1.Click
    Select * From testdata!customer Where cust_id = orders.cust_id
  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