Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checkbox in grid
Message
From
02/07/1997 08:40:18
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00038226
Message ID:
00038386
Views:
33
>>>I have a grid on a form with a column based on a logical field in a table. The column has the standard textbox plus a check box in it. The CurrentControl for the column is set to the check box. The ControlSource for the column is set to a UDF which will return "X" if the field is .T. and " " if .F. for the text box to display when the cell is not the active grid cell. The ControlSource for the check box is set to the logical field in the table. Sparse is set to .T., Bound for the column is set to .F..
>>>
>>>In the init of the grid the DynamicCurrentControl of the column is set as follows:
>>>
>>>THIS.COLUMN2.DYNAMICCURRENTCONTROL = "IIF( ( THIS.ACTIVECOLUMN = 2 AND RECNO() = THISFORM.LastRow ), 'Check1', 'TEXT1' )"
>>>
>>>THISFORM.LastRow is updated in the AfterRowColChange event of the grid.
>>>
>>>The effect I'm trying to get, of course, is when the cell is the active cell, the user sees the check box, otherwise the user sees the text box with an "X" or " " reflecting the logical contents of the field.
>>>
>>>This works well except for one problem, if the user tabs into the cell while on the same record, the check box displays correcly. But if the user moves into the cell from another record, the check box does not display and the field is always blank even if the field is .T.. If the user then tabs out of the field and back in while remaining on the same record, the check box correctly displays.
>>>
>>>What am I missing? This is in VFP5.0a.
>>>
>>>Thanks,
>>>Bill
>>
>>Maybe I misunderstood your problem, but why you cannot use checkbox only (deleting textbox from the column at all).
>
>why use a udf? checkbox should work fine for t/f (1 or 0). then bind object to field and see if it works.

As I suspected, these are quite viable solutions as long as you are willing to set the column's Sparse property to .F.. Otherwise the checkbox will appear only in the active cell. However setting Sparse to .F. for checkboxed columns can be prohibitively slow on some machines ( such as 486's of which there are still a lot around, like my current home machine :-) ), especially if you have 10 columns in the grid of which 5 will be checkboxed plus 2 others comboboxed with a bunch of necessary ( in my case ) processing taking place when the user changes rows.

At any rate, for the scenario I described, the solution turned out to be to update THISFORM.LastRow in the WHEN of the text boxes since the AfterRowColChange was firing too late. I wish there was some sort of "RowWhen" or equivalent for grids that was the first thing fired in the grid for the row when rows were changed.

Thanks for your input,
Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Previous
Reply
Map
View

Click here to load this message in the networking platform