Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid columns losing controlsource property
Message
From
28/04/2006 14:16:31
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01117583
Message ID:
01117612
Views:
23
>Alan,
>there has been quite a bit of discussion on this recently here on the UT. Not too many people seem to agree with my solution but I can tell you it works every time regardless of what you do with the cursors.

It's a very good solution! All the code is right at hand. It's a good compromise between visual and programmatic techniques.

>
>We create a procedure SetGrid that sets the record source of the grid and the control source of each column. It works even in the case where the grid has focus and you then change data sessions. Calling lSetGrid does all the work to reset the data.
>
>
Procedure lSetGrid
>lParameters oForm
>*
>With oForm.grdLines
>  .RecordSource = 'c_pssoln'
>  *
>  .Column1.ControlSource = 'c_pssoln.QtyOrd'
>  .Column2.ControlSource = 'c_pssoln.QtyShip'
>  .Column3.ControlSource = 'c_pssoln.QtyBo'
>  .Column4.ControlSource = 'c_pssoln.ManfId'
>  .Column5.ControlSource = 'c_pssoln.AltPart'
>  .Column6.ControlSource = 'c_pssoln.partno'
>EndWith
>
>
>>When in grid design mode (VFP8 SP1) I often omit the 'cursor.' prefix in column.controlsource to give me the flexibility to change the recordsource without having to adjust column properties. I change the recordsource at design-time all column.controlsource values are lost, even though the same field is present in the new recordsource. Is there any way of preventing this?
>>
>>I have experimented with a grid property .ColumnSourceList which contains a comma-delimited list of fields in column-display order (ie. field1,field2,field3,...). This list is parsed in grid.init and each column.controlsource loaded as appropriate. This works fine until I want to use a function in the list, and the function includes commas to separate arguments (eg. field1,field2,IIF(condition1,1,2),field4), which throws the parsing out completely.
>>
>>I would be interested to know how other developers have solved this problem. It would be nice not to have to reset all column.controlsource values when I change recordsource.
>>
>>TIA
>>
>>Alan
Previous
Reply
Map
View

Click here to load this message in the networking platform