Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enabling/Disabling controls in a grid
Message
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:
01246941
Views:
25
>>We have a grid whose record source is a view. Some of the columns are built at design time and others are added at run time.
>>
>>The problem we're having has to do with enabling and disabling a textbox control in column B based upon the checkbox control in column A. Clicking on the checkbox in a specific row will take care of the textbox just fine. However, when changing rows in the grid we cannot get the enabling/disabling to work reliably based on the value of the checkbox in column A within the current row.
>>
>>Any ideas?
>>
>>Laterness,
>>Jon
>
>Put in AfterRowColChange Event of the grid:
>
>this.ColumnB.text1.Enabled = NameOfTheRecordSourceOftheGrid.FieldThatIsBinedToColumn1
>
>
>Here a very simple example:
>
>oForm = CREATEOBJECT([Form1])
>oForm.Show()
>READ EVENTS
>
>DEFINE CLASS form1 AS form
>
>
>    DoCreate = .T.
>    Caption = "Form1"
>    Name = "Form1"
>
>
>    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],[CheckBox])
>         thisform.Grid1.Column1.Check1.Caption = []
>         thisform.Grid1.Column1.Check1.Visible = .t.
>         thisform.Grid1.Column1.CurrentControl = [Check1]
>         thisform.Grid1.Column1.removeObject([text1])
>    ENDPROC
>
>    PROCEDURE grid1.AfterRowColChange
>        LPARAMETERS nColIndex
>        this.Column2.Text1.Enabled = cTest.Fld1
>    ENDPROC
>
>        PROCEDURE Destroy
>                CLEAR EVENTS
>        ENDPROC
>ENDDEFINE
>
This doesn't have visual appearance unless you move to the record. I think we may use this solution for the readonly, but not for the enabled status.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform