Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Customized Header in Grid
Message
From
11/01/2010 12:01:51
 
 
To
11/01/2010 10:44:40
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01443157
Message ID:
01443263
Views:
50
>>>>This one is for VFP7, but answers that require VFP9 are also welcome.
>>>>
>>>>Is there any way to ' replace' the headers in a grid in a form with a custom header? I'm not talking about code generated forms and grids. I'm tallking about the form designer where a grid is added and the number of columns is still unknown.
>>>>
>>>>(Brings me on an idea: Create a grid class that has 10 columns and each header got the same custom code. Setting columncount to a lower value later is just another way than making it higher than -1. But this scenario might become a nightmare scenario because any maintenance would require 10 equal modifications in 10 places.)
>>>
>>>Define the header in code, then in the grid's init take the old one out with RemoveObject() and add the new one with Addobject()?
>>
>>Interesting idea. Did you test it?
>
>I did, even back in VFP7. I've found that the removeobject() is unnecessary, because a column must, at any time, have one and only one column. In the debugger, if you follow what's going on, you can see that as soon as you remove the header, it's replaced with a default header. But then, when you add a new header, the old one vanishes.
>
>IMO, the easiest (and what I have in code somewhere)
>
>save the caption and whatnot from the old header
>add the new header
>apply the saved properties
>bindevent to the new header any behavior you need.

After reading your comment I did this:

Create newheader.prg:
DEFINE CLASS MyHeader AS Header

   Caption = "Header"
   FontName = "Wingdings"
   FontSize = 8
   
   * put whatever behavior

ENDDEFINE
Create a form, add a table and drop that table on the form, thus creating a grid. Then enter the grid's Init method and add this:
set proc to newheader.prg

this.column1.addobject( 'header2', 'myheader' )
Then CTRL+E. And indeed the first column displays very nicely the caption in wingdings. This all in VFP7 indeed.

The funny thing is that its reference is now Header2, but that Header1 no longer exists indeed, as this code proofs. The first line creates an error.
wait wind this.column1.header1.caption
wait wind this.column1.header2.caption
Your words "because a column must, at any time, have one and only one column" should be "because a column can at any time have one and only one header".

Thanks :-)
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform