Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controlling fields displayed in a grid without columns
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00151310
Message ID:
00151642
Views:
20
Evan,

No, you do it at runtime assuming you know the names of the fields you want removed. Something like this Init from one of the grids I'm working on now. It's 5.0 code so you'll have to use this.Columns[i] instead of loCol.
bGrid::Init()

local loCol, lcDeleteCol

set classlib to projectmgr additive

for each loCol in this.Columns
   with loCol
      .Alignment = 4
      .Header1.Caption = proper( substr( .Header1.Caption, 2 ) )
      .Width = .Width * 0.85
   endwith

   do case
      case ( "iid" $ lower( loCol.ControlSource ) )
         * get rid of this column later
         lcDeleteCol = loCol.Name

      case ( "mnotes" $ lower( loCol.ControlSource ) )
         * make it an editbox
         with loCol
            .RemoveObject( "text1" )
            .AddObject( "edit1", "beditbox" )
            with .Edit1
               .Visible = .t.
               .SpecialEffect = 1
               .ReadOnly = .t.
            endwith
            .Sparse = .f.
            .Width = 200
         endwith
      otherwise
   endcase
endfor

with this
   .RemoveObject( lcDeleteCol )
endwith
And if you are going to go through and delete columns you can work backwards through the collection and just delete as you go.
for i = this.ColumnCount to 1 step -1
   if ( ( i % 2 ) = 0 )
      lcName = this.Columns[i].Name
      this.RemoveObject( lcName )
   endif
endfor
>Hi David. I am not sure what you mean. Do mean that I should invoke the grid builder? If not, the how do I know the name of the objects in the grid, since at design time there are none?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform