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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric Field Alignment in a Grid

Status
Not open for further replies.

carolx

Programmer
Jul 22, 2003
75
JM
Why when you use a table as the RecordSource in a grid the numeric fields are left-aligned and the leading zeros truncated whereas if you use a cursor the fields are right-aligned
 
That's not the case. Do you have the default setup of browse windows showing fields with a nonproportional font, eg courier new? In grids the default font differs, but by default numeric fields are right-aligned in grids. And there is no such thing as leading zeros in numeric fields unless you define a Format and/or inputmask to show such a thing. By default leading zeros are truncated.

What you see in a browse may be preformatted and configured and these settings are stored in the foxuser.dbf so you see the same tables with the same formattings and field and column widths etc. This is done for browse windows, not for grids. You need to customize a grid like you need to customize a browse and this is then stored in the SCX or form class, not in the foxuser.dbf. But by default both a browse and a grid show the same behavior in regard to numeric vs character fields.

Bye, Olaf.
 
Yes, I agree with Olaf.

In addition, if you create a grid by dragging from the data environment or the project manager, the columns will "inherit" the properties of the corresponding fields in the DBC. That includes things like format and input mask settings.

That's never the case with cursors. So, for that reason, grids based on cursors will always have the default settings unless you explicitly alter them in form/class designer.

Carolx, I suggeset you use the form/class designer to review the properties of the columns in question (and the controls within the columns). You'll probably see the setting that is causing this behaviour.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Let's also point out that
"in a grid the numeric fields are left-aligned and the leading zeros truncated"

There are NO 'Leading Zeros' in a numeric value so NO 'Leading Zeros' in a numeric field display.

If there is an expectation for the display to show 'Leading Zeros' then the field type and field value is NOT numeric.

Good Luck,
JRB-Bldr
 
I thought she meant 'leading spaces' as otherwise it wouldn't seem to be left justified.

B-)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top