Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comboboxes in Grid are blanked
Message
De
15/05/2018 12:23:16
 
 
À
11/05/2018 06:21:18
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
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:
01659996
Vues:
41
>>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
>
Thanks Cetin, I believe thar your solution is more elegant. Instead of having a bunch o comboboxes, show the textboxes and when in the textbox, it shows the combobox so that I can choose one of the available options.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform