Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing headers
Message
From
03/12/1998 12:12:20
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00163637
Message ID:
00163698
Views:
33
Getting the header into my grid, I think, can be done the same as with textboxes. I just run a program on the .SCX that replaces all of the classes.

The thing I'm missing is what would the header class look like? I don't know how to programatically make a header.

Thanks,

-Michelle

>Michelle,
>
>Headers have to be subclassed in a .PRG they can't be visually subclassed like most other classes. This also makes it tougher to use them because you can't have VFP use your Header class in the class/form designers. What you can do though is in the grid subclass Init() method is to replace the Header with your own header class. The code looks like:
>
>
if ( ! ( "CCONTROL.VCX" $ set( "classlib" ) ) )
>   set classlib to ccontrol additive
>endif
>
>if ( ! ( "CCONTROL.FXP" $ set( "procedure" ) ) )
>   * header class is in ccontrol.prg
>   set procedure to ccontrol additive
>endif
>
>local loHeader, lnX, lcX
>
>for i = 1 to tagcount()
>   lcTag = lower( tag(i) )
>   j = ascan( laControlSource, lcTag )
>   if ( j > 0 )
>      with this.Columns[j]
>         * copy object properties because they're not default values or come from dbc
>         lcX = .Header1.Caption
>         .RemoveObject( "Header1" )
>         .AddObject( "Header1", "hdrSeeker", lcTag )
>         .Header1.Caption = lcX
>
>         if ( type( .ControlSource ) == "C" )
>            .RemoveObject( "Text1" )
>            .AddObject( "Text1", "txtSeeker" )
>            with .Text1
>               .Visible = .t.
>               .mcTag = lcTag
>               .mlUpper = "UPPER" $ upper( sys( 14, i ) )
>            endwith
>         else
>            .ReadOnly = .t.
>         endif
>      endwith
>   endif
>endfor
>
>* make all col headers left aligned and switch the rest of the headers
>
>for each loCol in this.Columns
>   with loCol
>      .Header1.Alignment = 0
>      if ( .Header1.Class == "Header" )
>         lcX = .Header1.Caption
>         .RemoveObject( "Header1" )
>         .AddObject( "Header1", "hdrSeeker", "" )
>         .Header1.Caption = lcX
>         .Header1.FontBold = .f.
>      endif
>   endwith
>endfor
>
>
>This grid always builds itself, and I decided to just have the grid look to see if a tag existed at Init() time to know if the column should be sortable. If it is and it's a text field the Text1 is replaced with a txtSeeker class that does the incremental search dirty work.
>
>>I saw a trick where you can sort a column by clicking on the header. I'd like to use this, but it's too time consuming to add the code to every header. So I thought I'd make a header class. But VFP doesn't like it when I try to do that. Is there a way to subclass the header class?
>>
>>Another issue is putting indexes on every field in every table so it can sort. Is this a good idea? I'm wondering if that would slow things down significantly.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform