Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enabling/Disabling controls in a grid
Message
From
08/08/2007 23:28:52
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01135083
Message ID:
01246949
Views:
20
>This doesn't have visual appearance unless you move to the record.

Handle that with this in the init:

thisform.Grid1.Column2.DynamicForeColor="IIF(cTest.Fld1,RGB(0,0,0),RGB(128,128,128))"

The textbox in the row you're on won't change until you move off the check box, but I have a rather bizarre solution for that. I create a button that is off the grid, set focus to it, and it returns the focus back to the grid.

I mostly use this technique for running reports but it does work for updating the row display as well.
oForm = CREATEOBJECT([Form1])
oForm.Show()
READ EVENTS

DEFINE CLASS CheckX AS CheckBox
  PROCEDURE Click
    THISFORM.Offgrid.Visible = .t.
    THISFORM.Offgrid.setfocus()
    THISFORM.Offgrid.Visible = .f.
ENDDEF

DEFINE CLASS OffgridX AS textbox
  left = -100
  visible = .f.
  PROCEDURE gotfocus
    THISFORM.grid1.setfocus()
ENDDEF

DEFINE CLASS form1 AS form

    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"

    ADD OBJECT offgrid AS offgridx

    ADD OBJECT grid1 AS grid WITH ;
        ColumnCount = 2, ;
        Height = 200, ;
        Left = 29, ;
        RecordSource = "cTest", ;
        Top = 11, ;
        Width = 320, ;
        Name = "Grid1", ;
        Column1.ControlSource = "cTest.Fld1", ;
        Column1.Sparse = .F., ;
        Column1.Name = "Column1", ;
        Column2.ControlSource = "cTest.Fld2", ;
        Column2.Name = "Column2"

    PROCEDURE Load
        CREATE CURSOR cTest (Fld1 L, Fld2 C(20))
        FOR asd = 1 TO 20
            INSERT INTO cTest VALUES (asd%2 == 0, TRANSFORM(asd))
        NEXT
        LOCATE
    ENDPROC


    PROCEDURE Init
         thisform.Grid1.Column1.AddObject([Check1],[CheckX])
         thisform.Grid1.Column1.Check1.Caption = []
         thisform.Grid1.Column1.Check1.Visible = .t.
         thisform.Grid1.Column1.CurrentControl = [Check1]
         thisform.Grid1.Column1.removeObject([text1])
         thisform.Grid1.Column2.DynamicForeColor="IIF(cTest.Fld1,RGB(0,0,0),RGB(128,128,128))"

    ENDPROC

    PROCEDURE grid1.AfterRowColChange
        LPARAMETERS nColIndex
        this.Column2.Text1.Enabled = cTest.Fld1
    ENDPROC

        PROCEDURE Destroy
                CLEAR EVENTS
        ENDPROC
ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform