VFP 8: Is there anyway to control the margins that VFP uses when a grid's
.AutoFit() method is called? The default behavior of the AutoFit method
is to very tightly size column sizes. I would like to have a little more
whitespace between columns.
The only way I can think to do this is to convert all content to a
character data type and then append "N" number of spaces to the front and
back of each value.
Thanks!
Malcolm
Malcolm-
> VFP 8: Is there anyway to control the margins that VFP uses
> when a grid's
> .AutoFit() method is called? The default behavior of the
> AutoFit method is to very tightly size column sizes. I would
> like to have a little more whitespace between columns.
I know I should test this before posting, but does using the margin property
help?
Regards-
Nancy Folsom
Pixel Dust Industries
Author _Debugging_Visual_FoxPro_Applications_
Hi Nancy,
Thanks for the tip (re: use Textbox .Margin property) - it works - sort
of - but I think it also uncovers an AutoFit() bug or two.
1. AutoFit() appears to ignore the .Margin setting and autosizes based on
length of TextBox contents - not length of contents - .Margin * 2.
2. Cell highlighting within a cell with .Margin > 0 will only highlight
the data entry area within the TextBox - not the entire cell.
Code to reproduce these behaviors is included following my signature.
Are these worthy of bug reports to MS or are these behaviors "by design"?
Do you think I should re-title this thread some along the lines of
"Strange Grid behavior when textbox .Margin > 0"?
Thanks again for your help!
Malcolm
<open a table with 4 or more columns>
browse name loBrowse nowait
wait window "Before margin resize"
* NOTE: Have to set .Sparse to .F. to see .Margin effect
loBrowse.Column1.Text1.Margin = 8
loBrowse.Column1.Sparse = .F.
loBrowse.Column2.Text1.Margin = 8
loBrowse.Column2.Sparse = .F.
loBrowse.Column3.Text1.Margin = 8
loBrowse.Column3.Sparse = .F.
loBrowse.Column4.Text1.Margin = 8
loBrowse.Column4.Sparse = .F.
loBrowse.Refresh()
* after margin resize the whitespace looks good!
* BUT (another topic?) ugly cell highlighting
wait window "After margin = 8"
loBrowse.AutoFit()
loBrowse.Refresh()
* AutoFit doesn't appear to take into consider .Margin setting
wait window "After autofit"
----- Original message -----
From: "Nancy Folsom" <lists@pixeldustindustries.com>
To: profoxtech@leafe.com
Date: Fri, 14 May 2004 10:05:33 -0700
Subject: RE: Control margins used by grid AutoFit()
Malcolm-
> VFP 8: Is there anyway to control the margins that VFP uses
> when a grid's
> .AutoFit() method is called? The default behavior of the
> AutoFit method is to very tightly size column sizes. I would
> like to have a little more whitespace between columns.
I know I should test this before posting, but does using the margin
property
help?
Regards-
Nancy Folsom
Pixel Dust Industries
Author _Debugging_Visual_FoxPro_Applications_
http://www.hentzenwerke.com/catalogpricelists/debugvfp.htm
[excessive quoting removed by server]
Hi, Malcolm-
> Thanks for the tip (re: use Textbox .Margin property) - it
> works - sort of - but I think it also uncovers an AutoFit()
> bug or two.
>
> 1. AutoFit() appears to ignore the .Margin setting and
> autosizes based on length of TextBox contents - not length of
> contents - .Margin * 2.
>
> 2. Cell highlighting within a cell with .Margin > 0 will only
> highlight the data entry area within the TextBox - not the
> entire cell.
I ran your sample. The ugliness you see in the selected cell is the margin,
not anything to do with autofit. I'd never noticed it before but then I
never had such an obvious margin. It's ugly, for sure.
I see what you mean about AutoFit not recognizing the margin setting. Items
are truncated. So, two things, I'd call the latter issue a bug (AutoFit
should account for margins). The issue of padding the columns a bit...It
would be nice if we could, say, pass a parameter to AutoFit that would set a
padding amount. At this point it would seem to be your best bet to autofit,
then go through and increment the columns by a bit--not a great solution,
but still easier than doing the whole calculation ourselves, I guess.
Let me know if you decide to post the bug and/or design change request. If
it's on the UT, I'll vote for it.
Regards-
Nancy Folsom
Pixel Dust Industries
Author _Debugging_Visual_FoxPro_Applications_
http://www.hentzenwerke.com/catalogpricelists/debugvfp.htm
Hi Nancy,
Thanks for taking a look at my problem! I'm going to post 2 bugs and 2
design change requests.
BUG: Grid control's Autofit() method ignores Column's Textbox .Margin
property resulting in truncated display of Textbox contents.
CHANGE REQUEST: Have the grid control's AutoFit() method take an optional
parameter indicating the amount of margin (in pixels) to add to each
column when sizing columns.
BUG (?) and/or CHANGE REQUEST: Grid cells are not completely highlighted
when a column's Textbox's .Margin is greater than 0. Rather than
highlighting the data entry region of the Textbox control, the entire
grid cell region should be highlighted.
Anyone care to comment/edit these requests before I submit them to MS
(bug reports) and to the UT (change requests).
Thanks!
Malcolm
----- Original message -----
From: "Nancy Folsom" <lists@pixeldustindustries.com>
To: profoxtech@leafe.com
Date: Fri, 14 May 2004 15:50:33 -0700
Subject: RE: Control margins used by grid AutoFit()
Hi, Malcolm-
> Thanks for the tip (re: use Textbox .Margin property) - it
> works - sort of - but I think it also uncovers an AutoFit()
> bug or two.
>
> 1. AutoFit() appears to ignore the .Margin setting and
> autosizes based on length of TextBox contents - not length of
> contents - .Margin * 2.
>
> 2. Cell highlighting within a cell with .Margin > 0 will only
> highlight the data entry area within the TextBox - not the
> entire cell.
I ran your sample. The ugliness you see in the selected cell is the
margin,
not anything to do with autofit. I'd never noticed it before but then I
never had such an obvious margin. It's ugly, for sure.
I see what you mean about AutoFit not recognizing the margin setting.
Items
are truncated. So, two things, I'd call the latter issue a bug (AutoFit
should account for margins). The issue of padding the columns a bit...It
would be nice if we could, say, pass a parameter to AutoFit that would
set a
padding amount. At this point it would seem to be your best bet to
autofit,
then go through and increment the columns by a bit--not a great solution,
but still easier than doing the whole calculation ourselves, I guess.
Let me know if you decide to post the bug and/or design change request.
If
it's on the UT, I'll vote for it.
Regards-
Nancy Folsom
Pixel Dust Industries
Author _Debugging_Visual_FoxPro_Applications_
http://www.hentzenwerke.com/catalogpricelists/debugvfp.htm
[excessive quoting removed by server]
At 07:59 05/15/04 -0400, Malcolm Greene wrote:
>BUG: Grid control's Autofit() method ignores Column's Textbox .Margin
>property resulting in truncated display of Textbox contents.
Does it change anything if you have an InputMask that is wider than the field?
BUG (?) and/or CHANGE REQUEST: Grid cells are not completely highlighted
>when a column's Textbox's .Margin is greater than 0. Rather than
>highlighting the data entry region of the Textbox control, the entire
>grid cell region should be highlighted.
This one may well be by design (or by omission?). Highlighting the entire
box would give the impression that it is possible to enter more characters
than are available in the field. I've had users complain that "the entry
box was chopping off the names", when the box is significantly wider than
the field.
Dan Covill
San Diego
I'm working on a VFP form and I don't think I'm using a best practice
for AUTOFITting a grid. I've a pageframe with two pages, each page has
a grid. Many of these parent records have zero child sales records
and/or labor records. What's the best practice to get the grids to
AUTOFIT reliably?
Grids are set as:
ReadOnly = .T.
AllowCellSelection = .F.
In the THISFORM.LOAD() event, I create a cursor that I leave open for
the life of the form. When I navigate through the order records, I SQL
SELECT the child records, select the cursor that was created in the
LOAD(), ZAP it, and then append records from the cursor for the display
of the child records. This saves me from using views, and the
binding/unbinding problem with grids.
Here's the code I use to try to get that grid to autofit properly. This
code is *after* I've reloaded the records in the child cursor.
THISFORM.LockScreen = .T.
&& Lots of business stuff... including reloading the child cursor.
THISFORM.LockScreen = .F.
THISFORM.Pageframe1.Page1.grdSales.AutoFit()
THISFORM.Pageframe1.Page2.grdLabor.AutoFit()
THISFORM.Refresh()
The grids still aren't displayed with the optimized field sizes.
Harumph. Thanks for any help.
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/5582E0B5.4080007@cullytechnologies.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Kevin - although I have never used the Autofit Method (only the equivalent Property) - I saw in the Online help that it Returns a .T./.F. value based upon if it was successful.
Have you tested the return value? In your code below - I see that you are not even capturing the return value.
Anyway - it's just a thought...
-K-
-----Original Message-----
From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Kevin Cully
Sent: Thursday, June 18, 2015 11:16 AM
To: profoxtech@leafe.com
Subject: Grid Autofit
I'm working on a VFP form and I don't think I'm using a best practice for AUTOFITting a grid. I've a pageframe with two pages, each page has a grid. Many of these parent records have zero child sales records and/or labor records. What's the best practice to get the grids to AUTOFIT reliably?
Grids are set as:
ReadOnly = .T.
AllowCellSelection = .F.
In the THISFORM.LOAD() event, I create a cursor that I leave open for the life of the form. When I navigate through the order records, I SQL SELECT the child records, select the cursor that was created in the LOAD(), ZAP it, and then append records from the cursor for the display of the child records. This saves me from using views, and the binding/unbinding problem with grids.
Here's the code I use to try to get that grid to autofit properly. This code is *after* I've reloaded the records in the child cursor.
THISFORM.LockScreen = .T.
&& Lots of business stuff... including reloading the child cursor.
THISFORM.LockScreen = .F.
THISFORM.Pageframe1.Page1.grdSales.AutoFit()
THISFORM.Pageframe1.Page2.grdLabor.AutoFit()
THISFORM.Refresh()
The grids still aren't displayed with the optimized field sizes.
Harumph. Thanks for any help.
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/80838F1CA795B14EA1AF48659F35166F1C1DC5@DREXCH02.corp.globetax.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Have you tried refreshing the specific containers (i.e. the grid itself or the page or the pageframe)?
--
rk
-----Original Message-----
From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Kevin Cully
Sent: Thursday, June 18, 2015 11:16 AM
To: profoxtech@leafe.com
Subject: Grid Autofit
I'm working on a VFP form and I don't think I'm using a best practice for AUTOFITting a grid. I've a pageframe with two pages, each page has a grid. Many of these parent records have zero child sales records and/or labor records. What's the best practice to get the grids to AUTOFIT reliably?
Grids are set as:
ReadOnly = .T.
AllowCellSelection = .F.
In the THISFORM.LOAD() event, I create a cursor that I leave open for the life of the form. When I navigate through the order records, I SQL SELECT the child records, select the cursor that was created in the LOAD(), ZAP it, and then append records from the cursor for the display of the child records. This saves me from using views, and the binding/unbinding problem with grids.
Here's the code I use to try to get that grid to autofit properly. This code is *after* I've reloaded the records in the child cursor.
THISFORM.LockScreen = .T.
&& Lots of business stuff... including reloading the child cursor.
THISFORM.LockScreen = .F.
THISFORM.Pageframe1.Page1.grdSales.AutoFit()
THISFORM.Pageframe1.Page2.grdLabor.AutoFit()
THISFORM.Refresh()
The grids still aren't displayed with the optimized field sizes.
Harumph. Thanks for any help.
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/BN4PR10MB0913C572D21052DEF8DFAF30D2A50@BN4PR10MB0913.namprd10.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Hi,
I miss:
THISFORM.Pageframe1.Page1.grdSales.RecordSource = blahblah1.dbf
THISFORM.Pageframe1.Page2.grdLabor.RecordSource = blahblah2.dbf
also
AutoFit is a method, by default the columns are 'autofit', in your case you
give nothing in the method in my opinion superfluous
Rgds,
Koen
2015-06-18 17:29 GMT+02:00 Kurt Wendt <Kurt_Wendt@globetax.com>:
> Kevin - although I have never used the Autofit Method (only the equivalent
> Property) - I saw in the Online help that it Returns a .T./.F. value based
> upon if it was successful.
>
> Have you tested the return value? In your code below - I see that you are
> not even capturing the return value.
>
> Anyway - it's just a thought...
>
> -K-
>
> -----Original Message-----
> From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Kevin
> Cully
> Sent: Thursday, June 18, 2015 11:16 AM
> To: profoxtech@leafe.com
> Subject: Grid Autofit
>
> I'm working on a VFP form and I don't think I'm using a best practice for
> AUTOFITting a grid. I've a pageframe with two pages, each page has a grid.
> Many of these parent records have zero child sales records and/or labor
> records. What's the best practice to get the grids to AUTOFIT reliably?
>
> Grids are set as:
> ReadOnly = .T.
> AllowCellSelection = .F.
>
> In the THISFORM.LOAD() event, I create a cursor that I leave open for the
> life of the form. When I navigate through the order records, I SQL SELECT
> the child records, select the cursor that was created in the LOAD(), ZAP
> it, and then append records from the cursor for the display of the child
> records. This saves me from using views, and the binding/unbinding problem
> with grids.
>
> Here's the code I use to try to get that grid to autofit properly. This
> code is *after* I've reloaded the records in the child cursor.
>
>
> THISFORM.LockScreen = .T.
> && Lots of business stuff... including reloading the child cursor.
> THISFORM.LockScreen = .F.
>
> THISFORM.Pageframe1.Page1.grdSales.AutoFit()
> THISFORM.Pageframe1.Page2.grdLabor.AutoFit()
> THISFORM.Refresh()
>
> The grids still aren't displayed with the optimized field sizes.
> Harumph. Thanks for any help.
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CACUu1SvpmQeaezYMnV02g88z4LNpcrPEMyhJ=_xNhiFhLxX0tA@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.