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

Grid Column Positions on the form

Status
Not open for further replies.

andy0923

Programmer
Jul 26, 2002
65
US
I am interested in calculating the location (left position) of each column in a grid with respect to the form ( and not with respect to the grid).

Does anyone know how to do this? I have tried
grid.columns(x).controls[2].left but do not get an accurate measurement of precisely the start of each column.

Any help is appreciated.
 
Hi
to do this you must calculate

Left position from grid is
eq. thisform.grid1.left - so X from start of form

than if You wish to know where eg.
started Column2
You must add
thisform.grid1.left+thisform.grid1.Column1.width

that will be start of column2 relative to Form
left X of grid + Width Column1
and recursive to other columns

Procedure to_Calculate
parameters col_no
startx=thisform.grid1.left

for i=0 to col_no-1
if i>0
field_to_add="thisform.grid1.Column"+alltrim(str(i))+".width"
__value=&field_to_add
startx=startx+__value
endif
endfor
WAIT WINDOW STR(startx)



Thats all
Best Regards
Jerzy
 
Thank you - I was doing nearly the same thing. However, I found that starting the counter at one, and accumulating the str(k-1) value gave me almost what i want.

The positions start to be imprecise after a few columns depending on the column length. I guess i'll have to provide an adjustment routine.

But without your help I wouldnt have realized the k-1 mistake. Thanks again.
 

Andy,

The result might also depend on the setting of the GridLines property. If this is set to 2 or 3, you might have to allow for the width of the vertical lines between the columns -- probably one pixel per column.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike - Thats exactly the information I was looking for - What I decided to do was to add a bit on every third or fourth column as a compensation. Will also try adding one to every column.

Thanks again, Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top