Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lookup Combo in Grid
Message
From
05/07/2006 09:23:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/07/2006 06:06:33
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01133757
Message ID:
01133794
Views:
21
>Hi at all,
>
>I have the following situation
>
>Table name.dbf
>Code c(4)
>Description c(20)
>
>Table data.dbf
>xxxx c(2)
>yyyy c(2)
>Code c(4)
>
>
>I have a grid for table data.dbf and in the column of Code I have insert a combo with following settings:
>
>BoundColumn = 2
>ColumnCount = 2
>ColumnWidths = 75,0
>ControlSource = table.code
>RowSourceType = 6-Fields
>RowSource = name.descritpion,code
>Style = 2 - Dropdown List
>
>It works fine if I set the Sparse setting of column = .f. but I want to have the combo visible only if the customer click in row, this works if I set the sparse setting to .t. but the value displayed in column is obviusly the code and not the descriprtion is there any solution or idea for this situation.
>
>Thank you in dvance for any help.
>
>regards
>Luigi

You need some code + column.bound=.f. to do that. Here is a sample:
Public oForm
oForm = Createobject('comboingrid')
oForm.Show

Define Class comboingrid As Form
  Top = 0
  Left = 0
  Height = 350
  Width = 620
  DataSession=2

  Add Object grdorditems As Grid With ;
    Height = 300, ;
    Left = 10, ;
    Top = 10, ;
    Width = 600, ;
    Rowheight = 19,;
    RecordSource = "orditems", ;
    Name = "grdOrditems"

  Procedure Load
    Use _samples+'Data\orditems' Order Tag order_id
    Use _samples+'Data\products' In 0 Order Tag product_id
    Set Relation To product_id Into 'products' In 'orditems'
    Set Multilocks On
    CursorSetProp("Buffering",5,'orditems')
    CursorSetProp("Buffering",5,'products')
  Endproc

  Procedure Init
    With This.grdorditems.Column3
      .Bound = .F.
      .ControlSource = "Products.prod_name"
      .Width = 170
      .AddObject('comboincol','comboincol')
      .comboincol.Visible = .T.
      .CurrentControl = 'comboincol'
    Endwith
  Endproc
Enddefine

Define Class comboincol As ComboBox
  Height = 19
  BorderWidth = 0
  BoundColumn = 2
  BoundTo = .T.
  ColumnCount = 2
  ColumnWidths = "180,0"
  RowSourceType = 3
  RowSource = "select products.prod_name,product_id"+;
              " from products"+;
              " into cursor crsProducts"+;
              " order by 1"
  SpecialEffect = 1
  Style = 2

  Procedure Valid
    Replace product_id With crsProducts.product_id In 'orditems'
  Endproc

  Procedure When
    Select crsProducts
    Locate For product_id == orditems.product_id
    This.DisplayValue = crsProducts.prod_name
  Endproc
Enddefine
PS: Buffering here in sample is used to keep original data intact.
You might choose another rowsourcetype for combo but IMHO this has much more advantages over others.

And BTW congratulations for making it to semifinals. It was a spectacular match:)
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