Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids 101 - why am I so lost ?
Message
From
14/12/2006 13:31:16
 
 
To
14/12/2006 12:38:38
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01177450
Message ID:
01177703
Views:
18
Thanks very much Edward for that code. I made a change or two to reflect my Product table and your grid object comes a lot closer than mine! Actually, with a few tweaks it would probably do excatly what I want! But I still want to figure out what is going on when RowSource = Alias (or Fields). Chalk it up to the flat learning curve :)

>>>New to VFP, I've now got about 30 hours into trying to make a grid work with a combo box. Here is a simplified outline of what I am trying to do. Greatly appreciate any suggestions!
>>>
>>>I have an invoice detail table(I) and a products table(P). I defined my grid's RecordSourceType=Alias, RecordSource=I etc. I want my grid as follows:
>>>
>>>Part# Description Qty Price
>>>------ ------------- --- -----
>>>
>>>Part# - combo box: 0-Dropdown, RowSource=P.PartNo,PartDesc, ControlSource=I.PartNo
>>> dropdown list will display "Part# | Description"
>>>
>>>Description - text box - ControlSource=P.PartDesc (read-only, not saved in I)
>>>
>>>Qty - text box: ControlSource = I.Quantity
>>>
>>>Price - text box: ControlSource=I.Price
>>>
>>>
>>>My problem is that a grid configured this way behaves quite odd: when the combo's list (Part#) drops down, it clears the instant I press any key. I think VFP is seeking in the Products table, trying to update the Description column? But shouldn't the combo remain dropped down until user selects something, hits ESC etc ? If I change Description column's ControlSource to (none) and its text box's Value property to "Test Description", the Description column will display "Test Description", but ONLY when that column has the focus (blank otherwise). So I guess my question is how do I display a calculated value for a column - regardless of whether column has focus ? Again, setting Description column's ControlSource=P.PartDesc causes all kinds of screwy behavior with the Part # combo box.
>>>
>>>I have a hunch I could avoid all these problems if I used an array RowSource for the combo. But I really want to learn from this "episode". I hate giving up :)
>>>
>>>Many thanks!
>>>
>>>PS. How do you change UT forum messages to use fixed fonts, so columns line up?
>>
>>Probably you set style to worng value (default for example). 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
>>    Set Multilocks On
>>    CursorSetProp("Buffering",5,'orditems')
>>  Endproc
>>
>>  Procedure Init
>>    With This.grdorditems.Column3
>>      .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"+;
>>                " from products into cursor crsProducts order by 1"
>>        .SpecialEffect = 1
>>        .Style = 2
>>        .ControlSource = "orditems.product_id"
>>        .Visible = .T.
>>      Endwith
>>      .CurrentControl = 'comboincol'
>>    Endwith
>>  Endproc
>>Enddefine
>>
IMHO grids are hard to harness. But if you can harness, there is no other control in VFP as powerfull as it is (as BROWSE is maybe the most powerfull command of FoxPro at all times - wish grids could have all power of a browse and added upon it). I wouldn't discourage using grids for data entry (and even would encourage:) but I know I'm in minority as well.
>>PS: Due to grids' power, in my applications, generally there isn't Top/Prev/Next/Last navigation buttons at all and users love seeing their data in grids and quickly navigating/sorting etc.
>>Long live grid:)
>>Cetin
>
>I always use grid for searches, though some innocent users get worried initially. Nav.buttons I add as a premium, when a client gives me more time :)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform