Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I disable one row on a grid?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00391037
Message ID:
00391610
Views:
19
>>>>>Suppose I have a grid that's running off of a table. The grid displays 4 fields across from this table. When the third field is TRUE for particular line, I want this line of the grid to be disabled. How do I do this?
>>>>
>>>>Only the ActiveRow or all diplayed rows with the third field TRUE?
>>>>
>>>>Take a look at the Grid's DynamicCurrentControl property. It could be used to do what you want. It does cost some performance - The expression is evaluated for every row showing in the grid everytime the grid refreshs.
>>>
>>>It's a grid's column property. It's not per row but per column control. The usage of which is how to interchange controls in a column.
>>
>>The sentence: When the third field is TRUE for particular line, I want this line of the grid to be disabled.
>>
>>To me reads : When the third field (column) for a particular line (row) is TRUE I want to disable the line (row) of the grid disabled.
>>
>>Either way the DynamicCurrentControl property will do the trick.
>
>How?

Jess,

Sorry for the typo - I meant GRID COLUMN's DynamicCurrentControl property.

Add a Load method to a grid.
Set the grid's columncount to 0.
Pass it the name of the cursor to load.

I just roughed it out with copy/paste, left out some class definitions but it shows you How... Here's the code...

PROCEDURE LOAD
LPARAMETER tcAlias

THIS.RECORDSOURCE = tcAlias
THIS.ROWHEIGHT = 30

THIS.ADDOBJECT('Column1','App_Column')
WITH THIS.Column1

.oHeader.CAPTION = 'Column 1'
.WIDTH = 35
.SPARSE = .F.

.ADDOBJECT('txtEnable','textbox_Enable')
.ADDOBJECT('txtDisable','textbox_Disable')

.DYNAMICCURRENTCONTROL = 'IIF('+ALLTRIM(THIS.RECORDSOURCE)+'.third_field,"txtDisable","txtEnable")'
ENDWITH

THIS.ADDOBJECT('Column2','App_Column')
WITH THIS.Column2

.oHeader.CAPTION = 'Column 2'
.WIDTH = 35
.SPARSE = .F.

.ADDOBJECT('txtEnable','textbox_Enable')
.ADDOBJECT('txtDisable','textbox_Disable')

.DYNAMICCURRENTCONTROL = 'IIF('+ALLTRIM(THIS.RECORDSOURCE)+'.third_field,"txtDisable","txtEnable")'
ENDWITH

THIS.ADDOBJECT('Column3','App_Column')
WITH THIS.Column3

.oHeader.CAPTION = 'Column 3'
.WIDTH = 35
.SPARSE = .F.

.ADDOBJECT('txtEnable','textbox_Enable')
.ADDOBJECT('txtDisable','textbox_Disable')

.DYNAMICCURRENTCONTROL = 'IIF('+ALLTRIM(THIS.RECORDSOURCE)+'.third_field,"txtDisable","txtEnable")'
ENDWITH

THIS.ADDOBJECT('Column4','App_Column')
WITH THIS.Column4

.oHeader.CAPTION = 'Column 4'
.WIDTH = 35
.SPARSE = .F.

.ADDOBJECT('txtEnable','textbox_Enable')
.ADDOBJECT('txtDisable','textbox_Disable')

.DYNAMICCURRENTCONTROL = 'IIF('+ALLTRIM(THIS.RECORDSOURCE)+'.third_field,"txtDisable","txtEnable")'
ENDWITH

ENDPROC

DEFINE CLASS App_Column AS COLUMN

PROCEDURE INIT
THIS.REMOVEOBJECT('Header1')
THIS.REMOVEOBJECT('Text1')
THIS.ADDOBJECT('oHeader','App_Header')
ENDPROC

ENDDEFINE

Bill
Heavy Metal Pedal - click with care
Previous
Reply
Map
View

Click here to load this message in the networking platform