Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comboboxes in Grid are blanked
Message
De
11/05/2018 06:21:18
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/05/2018 21:29:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01659916
Message ID:
01659927
Vues:
61
This message has been marked as the solution to the initial question of the thread.
>Hi All, I created a grid that has several columns, two of them have a combobox inserted as the current control and the Sparse property is set to ,F, so that the comboboxes appears in all rows of the grid (as you can see in the attached figure), I select values from the comboboxes in every row, but when I move around the grid, the DisplayValues (not the values) of the comboxes are blanked and then returned to the original DisplayValue o viceversa. How can I avoid this weird behavior? Is there a better solution? My cusetomer doesn't want to show a new form every time a row is added to the grid, that's why I chose to use comboboxes this time.
>
>BTW, the comboboxes are well built, I tested them before insert them in the columns.

Hi Luis,
I remember combo in grid was always problematic. IMHO below sample is a better approach (BOUND=.F.):
Public oForm
oForm = Createobject('comboSample')
oForm.Show

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

  Add Object grdItems As Grid With ;
    Height = 300, ;
    Left = 10, ;
    Top = 10, ;
    Width = 600, ;
    Rowheight = 19,;
    RecordSource = "crsItems"

  Procedure Load

    Select Cast(.Null. As Int) As ProductID, Cast('' As c(50)) As prod_name ;
      FROM (_samples+'Data\products') ;
      UNION ;
      select Int(Val(product_id)) As ProductID,prod_name ;
      FROM (_samples+'Data\products') ;
      INTO Cursor crsProducts ;
      readwrite
    Index On ProductID Tag ProductID

    Create Cursor crsItems ;
      (LINE_NO i, ORDER_ID c(6), ;
      ProductID i Null, UNIT_PRICE Y, QUANTITY i)

    Insert Into crsItems ;
      Select LINE_NO, ORDER_ID, ;
      Val(product_id) As ProductID, ;
      UNIT_PRICE, QUANTITY ;
      From (_samples+'data\orditems')
    locate  

    Use In 'products'
    Use In 'orditems'

  Endproc

  Procedure grdItems.Init
    Local ix
    With This
      .Rowheight=22
      For ix = 1 To .ColumnCount
        If Upper(Justext(.Columns(m.ix).ControlSource)) == 'PRODUCTID'
          With .Columns(m.ix)
            .Bound = .F.
            .ControlSource = "(Iif(Seek(crsItems.productid,"+;
              "'crsProducts','productID'),crsProducts.prod_name,''))"
            .Width = 180
            .Alignment = 0
            .AddObject('comboincol','combobox')
            With .ComboIncol
              .BoundColumn = 2
              .BoundTo = .T.
              .ColumnCount = 2
              .ColumnWidths = "180,0"
              .RowSourceType = 3
              .RowSource = "select prod_name,productID"+;
                " from crsProducts"+;
                " order by 1" +;
                " into cursor crsComboSource"
              .SpecialEffect = 1
              .Style = 2
              .ControlSource = "crsItems.productID"
              .Visible = .T.
            Endwith
            .CurrentControl = 'comboincol'
          Endwith
          Exit
        Endif
      Endfor
      .AddColumn(.ColumnCount+1)
      .Columns(.ColumnCount).Name = 'showProdID'
      .ShowProdID.ControlSource = '(crsItems.ProductID)'
    Endwith
  Endproc
Enddefine
Ç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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform