Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to re-create all columns in grid
Message
 
 
To
14/09/2001 14:35:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00556193
Message ID:
00556722
Views:
35
First I created a copy of my Foxuser table and called it FXUser.dbf/fpt. I put a grid on a form and named it Grid1. In the Click of a command button I placed the following code:
LOCAL lcSource, lnCount, lnI, lnJ, lnK
FOR lnJ = 1 TO 1000
   WITH ThisForm.Grid1
      lcSource = .RecordSource
      .RecordSource = ""
      lnCount = .ColumnCount
      FOR lnI = lnCount TO 1 STEP -1
         .RemoveObject(.Columns(lnI).Name)
      ENDFOR
      FOR lnI = 1 TO 3
         .AddObject('Column' + TRANSFORM(lnI), 'Column')
         IF lnI = 2
            .Columns(lnI).AddObject("Combo1", "Combobox")
            .Columns(lnI).RemoveObject("Text1")
            .Columns(lnI).CurrentControl = "Combo1"
         ENDIF
         .Columns(lnI).Visible = .t.
      ENDFOR
      lnK = 1
      .RecordSource = (lcSource)
      FOR lnI = 1 TO 3
         DO WHILE lnK <= FCOUNT(lcSource) AND NOT INLIST(TYPE(FIELD(lnK)), "C", "D")
            IF lnK > FCOUNT(lcSource)
               EXIT
            ENDIF
            lnK = lnK + 1
            LOOP
         ENDDO
         .Columns(lnI).ControlSource = lcSource + "." + FIELD(lnK)
         lnK = lnK + 1
      ENDFOR
   ENDWITH
ENDFOR
I have clicked the button several times and got no C5 error. Please try exactly what I did and see if you get the error.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform