×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Some misunderstand in Grid
2

Some misunderstand in Grid

Some misunderstand in Grid

(OP)

Hello Colleagues!

I have some small aesthetics problems with this Grid:



1) I am trying to change the color for the Grid Header, but in Grid Properties I don't see something like HeaderBackColor.

2) Also, I would like the contents of columns 1 and 6 to say at the header botton. I change the Properties of the Column1, Alignment to '9-Bottom Center' but the content of Column 1 stays in the above position!

3) And also the position of the contents inside the columns 2 to 9 are not centralized, even they are set '2-Center' in the Text, Alignment properties.

Thank you,
SitesMasstec

RE: Some misunderstand in Grid

1. Change colour of column 1's heading:

THISFORM.Grid1.Column1.Header1.Backcolor = RGB(<whatever>)

2. Vertical alignment of headings. You need to do this for the Header, not the column.

THISFORM.Grid1.Column1.Header1.Alignment= 9

3. Alignment of the text in the columns: You need to do this for the column, not the textbox:

THISFORM.Grid1.Column1.Alignment = 2

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Some misunderstand in Grid

I've shown you how to do it for a single column. To apply the same change to all the columns, you could repeat the code for each column in turn. Or you could use the SetAll() method. For example, to change the alignment of all the columns:

THISFORM.Grid1.SetAll("Alignment", 2, "Column")

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Some misunderstand in Grid

To get BackColor working you also need to turn off Windows Themes rendering, that means use SYS(2700,0). A little warning, that'll turn off many gradient background color renderings and will let the whole screen look different, you might need to adjust more.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Some misunderstand in Grid

(OP)
Hello colleagues!

Mike, I use all your advices in Form1, Init and none of the 3 commands worked! Or as Olaf warned, I should turn off Windows Themes rendering. But I do not want to change other Windows looks different, for I have users who have Windows XP, 7, 8 & 10 environments, and it would be messing.

That exposed, I understand that all Grid Header will be in gray color (not a good appearance), isn't it?

Thank you,
SitesMasstec

RE: Some misunderstand in Grid

You misunderstand. SYS(2700,0) turns off Windows Themes for your application only, it doesn't turn off Windows Themes overall.
If you're in doubt about such a thing, it also helps to refer to the help, once you know SYS(2700) and you can simply try.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Some misunderstand in Grid

I suggest you also look at the Themes property. This is what the Help says about Grid.Themes:

Quote:

For a Grid control, Themes affects the visual appearance of column headers. If themes are enabled for a grid, the BackColor and ForeColor properties of the header are disregarded because they inherit the attributes of the theme. However, the BackColor and ForeColor properties of a Column object display independently from the setting of a grid's Themes property.

The difference between the Themes property and SYS(2700) is that the former can be applied to a specific control, whereas the SYS() function applies to VFP as a whole.

I usually turn themes off for a grid. I have no problem setting the colours to anything I like.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Some misunderstand in Grid

(OP)
Hello colleagues!

With your valuable help, I am almost there! (the position of the contents inside the columns 2 to 9 are not centralized yet)

Please look at the fields inside the red marked retangle:


In the Form1 Init I have:

CODE --> VFP9

THISFORM.Grid1.Column1.Text1.Alignment= 1   && Left

THISFORM.Grid1.Column2.Text1.Alignment= 2   && Center
THISFORM.Grid1.Column3.Text1.Alignment= 2
THISFORM.Grid1.Column4.Text1.Alignment= 2
THISFORM.Grid1.Column5.Text1.Alignment= 2
THISFORM.Grid1.Column6.Text1.Alignment= 2
THISFORM.Grid1.Column7.Text1.Alignment= 2
THISFORM.Grid1.Column8.Text1.Alignment= 2
THISFORM.Grid1.Column9.Text1.Alignment= 2 

It doesn't obey centralization of columns 2 through 9. An explanation:
The fields TACOENKCQT, TACOCARBQT, TACOPROTQ, etc (from the command bellow) are all Character type, and all have 10 bytes. So the value 363 in column 2, row 1 in fact comes from the table TACOCAR.DBF, which keeps it "363 " (10 characters) in the table. Is this the problem of non centralization in the grid?

CODE --> VFP9

SELECT TACODESCRI, TACOENKCQT, TACOCARBQT, TACOPROTQT, TACOFIBRQT, TACOSODIQT, TACOCOLEQT, TACOCALCQT, TACOFERRQT FROM TACOCAR ;
WHERE UPPER(ParteQualTaco) = UPPER(LEFT(TACOCAR.TACODESCRI,LenParteQualTaco)) ;
INTO CURSOR TEMPTACO
thisform.Grid1.RecordSource = "TEMPTACO" 

Thank you,
SitesMasstec

RE: Some misunderstand in Grid

Two ideas: While there is the text1 control in a grid column with all the usual properties for databinding (controlsource) and formatting of data (alignment=) all these things should mainly be controlled by thegrid.column. So rather set

CODE

THISFORM.Grid1.Column1.Alignment= 1   && Left

THISFORM.Grid1.Column2.Alignment= 2   && Center
THISFORM.Grid1.Column3.Alignment= 2
THISFORM.Grid1.Column4.Alignment= 2
THISFORM.Grid1.Column5.Alignment= 2
THISFORM.Grid1.Column6.Alignment= 2
THISFORM.Grid1.Column7.Alignment= 2
THISFORM.Grid1.Column8.Alignment= 2
THISFORM.Grid1.Column9.Alignment= 2 

Then you're not storing "363" in a char(10) field, you're storing "363 ", what you'd actually like to center is the alltrimmed value, you better design the tablel with varchar fields to get that trimming automatic. You could now go for centering the value within the char(10) yourself, but that'll not really make you happy with allignments. Besides numbers arebest aligned right for obvious reasons, but that's of course up to you.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Some misunderstand in Grid

Quote (Olaf)

numbers are best aligned right for obvious reasons, but that's of course up to you.

Yes, I agree with that.

Sites, for your first column, if there are always exactly three digits, you can simply place a couple of spaces before the contents of the field to make it look approximately centred. You can do that in your SELECT:

SELECT " " + TACODESCRI As TACODESCRI, ....

For the columns that have a decimal point, I think you'll find they look better if have the same number of digits after the point, and you right-align them:

SELECT ..., TRANSFORM(TACOENKCQT, "9999.99") As TACOENKCQT, ...

Just my personal opinion.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Some misunderstand in Grid

(OP)

Mission accomplished!!! (with the help od Mike and Olaf)

Now I used Varchar, as Olaf advised me for the contents of the grid to be centralized.
(I am using Varchar for the first time --- and I had wondered before, where I will use this field type.)


Thank you,
SitesMasstec

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close