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: Ellen Solomon
  Where is Ellen Solomon?
 Bet Shemesh
 Israel
 Ellen Solomon
 Tags
Subject: RE: display problems w/ combo box in grid
Thread ID: 393832 Message ID: 393833 # Views: 61 # Ratings: 3
Version: Visual FoxPro 9 Category: Grids
Date: Tuesday, December 24, 2013 1:00:11 PM         
   


> Hi!
>
> I have a combo box within a grid. The column is set to sparse = F.
>
> The combo box RowSource is a table alias with columns (Desc c(20), Code n(4))
> bound column = 2
> bound to = t
> column widths = 150,0
> column count = 2
> format = !
>
> The description displays great, and with BoundTo = T the ControlSource gets the right value. Everything works great, except one thing: when a cell is not dropped down but has focus it is blank.
>
> I tried to change the column to Sparse = T but then it only shows the description when it has focus, otherwise it shows the numeric setting.
>
> Any suggestions?
>
> Thanks,
> Ellen


*!*	Combobox in a grid column sample
*!*	Author:Cetin Basoz

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"

  Procedure Load
    Use _samples+'Data\products' In 0
    Use _samples+'Data\orditems' In 0 Order Tag order_id
    Set Multilocks On
    CursorSetProp("Buffering",5,'orditems') && we don't want to save edits in test mode
  Endproc

  Procedure grdorditems.Init
    Local ix
    With This
      For ix = 1 To .ColumnCount
        If Upper(Justext(.Columns(m.ix).ControlSource)) == 'PRODUCT_ID'
          With .Columns(m.ix)
            .Bound = .F.
            .ControlSource = "(Iif(Seek(orditems.product_id,"+;
              "'products','product_id'),Products.prod_name,''))"
            .Width = 170
            .AddObject('comboincol','combobox')
            With .ComboIncol
              .BoundColumn = 2
              .BoundTo = .T.
              .ColumnCount = 2
              .ColumnWidths = "180,0"
              .RowSourceType = 3
              .RowSource = "select products.prod_name,product_id, unit_price"+;
                " from products into cursor crsProducts order by 1"
              .SpecialEffect = 1
              .Style = 2
              .ControlSource = "orditems.product_id"
              .Visible = .T.
            Endwith
            .CurrentControl = 'comboincol'
          Endwith
          Exit
        Endif
      Endfor
    Endwith
  Endproc

  Procedure grdorditems.BeforeRowColChange
    Lparameters nIndex
    If Type('this.Columns(m.nIndex).ComboInCol') = 'O' && Column with combo we added
      Select (This.RecordSource)
      Replace unit_price With crsProducts.unit_price
      This.Refresh()
    Endif
  Endproc
Enddefine





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

display problems w/ combo box in grid Posted by Ellen Solomon @ 12/24/2013 12:48:01 PM
RE: display problems w/ combo box in grid Posted by Cetin Basoz @ 12/24/2013 1:00:11 PM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/24/2013 1:08:51 PM
RE: display problems w/ combo box in grid Posted by Cetin Basoz @ 12/24/2013 2:01:25 PM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/24/2013 1:06:22 PM
RE: display problems w/ combo box in grid Posted by Ellen Solomon @ 12/25/2013 7:45:06 AM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/25/2013 6:32:09 PM