Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming Grid Colums Header

Status
Not open for further replies.

Jomercat

Programmer
Sep 1, 2004
100
US
Hi all,

Hope somebody can help.

I am working in a VFP 9 project for which I need to rename the grid column header.

Does anybody know how to do this?

Any help would be appreciated.

Jose.
 

Jose,

When you say "rename", do you really mean you want to change the Name property? If so, select the grid in the form designer, then go into the property sheet. Open the drop-down list at the top, and select Column1. Then go to the Name property and type the new name.

If in fact you want to change the caption, then the process is similar. In that case, you choose the Header1 rather than Column1, then change the Caption property.

Repeat the process for each column.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You can do the same that Mike suggests programatically if required by adding code within your application to make the Header1.Caption change

Code:
ThisForm.Grid1.Column3.Header1.Caption = "New Col Header"
ThisForm.Grid1.Refresh

Good Luck,
JRB-Bldr

 
Thanks guys for replying!!!

I am sorry, what I meant to say is to change the header caption for the columns.

What I have is a cursor which has the departments in our company. The cursor includes the Department ID, a Week ID, and the available working hours per week.

Department ID Week ID Hours
AAAAAA 20060101 100
BBBBBB 20060101 200
AAAAAA 20060108 300
BBBBBB 20060108 400
AAAAAA 20060115 500
BBBBBB 20060115 600

Within the cursor I am fetching the records so tha it will populate the records as folows.

Department ID Week 1 Week2 Week 3
AAAAAA 100 300 500
BBBBBB 200 400 600

What I want to do is change the header's caption to the Week Id instead of Week 1 Week 2..... As I have it.

Thanks.

Jose.
 
MikeLewis,

I have the captions as week 1, week 2....... already. What I need to do is change that caption to the week ID data field. In other words, instead of week 1, week 2, etc, I want to change it to 20060101, 20060108, and 20060115.

Jose.
 
Jose,

Now what is still confusing you? Just because a cursor has a field name week1, the caption can also be "20060101". The grid only by default sets all column header captions to field names.

I assume you use the Cross-Tab wizard to transform the data from the form with the weekID fiedl to the form displayed with several week1, week2 etc. fields.

And your real problem may be that you don't know what weekID results to some week1, week2 etc. column. As pure numbers are not allowed as field names, a solution may be to compute field names as "_"+transform(weekID) instead of "week"+alltrim(str(n)) or something. then you could simply remove the "_" from the field name to compute the caption. Another solution would be creating some cursor where you store which weekID is transformed to which field name and then replace the caption accordingly, after you set the controlsource of the grid to the displayed cursor.

Bye, Olaf.
 

Jose,

I'm stuggling to understand what the problem is. We've told you what you need to know about changing captions in a grid. It now looks like you're asking how to convert a string in the formn "Week N" to a sting in the form "YYYYMMDDD".

I suggest you sit down and think carefully about exactly what question you are asking. If -- as I now suspect -- it is concerned with converting date formats, and nothing to do with captions or grids, you should re-post the question as a new thread with a suitable title (in the appropriate forum, which is probably General Coding Issues).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top