Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid weirdness
Message
 
 
To
04/12/2001 18:33:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00589570
Message ID:
00589633
Views:
27
>Hi All,
>
>OK I have a grid that displays through various cursors the info from the same table. When the users change from one cursor to the other, I need column widths to change as well. I cobbled together the following code:
>
>with thisform.grdInven
> for i = 1 to .columncount && number of columns in cursor
> .columns(i).width = len(.columns(i).header1.caption)
> endfor
>endwith
>
>The problem I have is that when I return the column width, it is in units much smaller than what I am used to working with. Does anyone know of a conversion I can slip into the code?
>
>Thanks,

Here is the code fragement (old code, since it's from home) from my grid class:
if this.recordsourcetype=1 OR this.recordsourcetype=0 && Alias or table
     select (this.recordsource)
     lnWidthTotal= iif(this.recordmark, 10,0)+ iif(this.scrollbars>1,sysmetric(5),0) ;
          + 2 * this.gridlinewidth + iif(this.deletemark, 10,0)+10 && record marker & vertical scroll bar+deletion mark
     for each loColumn in this.columns
          * -- For each column determine the width and use the correct caption.  
          * -- Display the caption via the proper() function.
          lcFieldName=alltrim(substr(loColumn.controlsource,rat('.',loColumn.controlsource)+1))
          lcFieldType=type(lcFieldName)
          lnFWidth=iif(lcFieldType='D',13,iif(lcFieldType='T',28,fsize(lcFieldName)+3)) && Field size
          for each loControl in loColumn.controls
               if lower(loControl.baseclass) = "header"
                    * Handle condition of header set in grid.
                    if lower(left(loControl.caption,6))='header'  && Don't override a preset caption
                         * -- NSL Use the DBC caption if it exists.
                         loControl.caption=dbgetprop(loColumn.controlsource,'field','caption')  
                    endif
                    if empty(loControl.caption)  && There is no DBC caption, Just use the Field name
                         loControl.caption=proper(lcFieldName)
                    else
                         loControl.caption=proper(loControl.caption)  && If it has been coded in the grid, use it.
                    endif

                    lnCWidth=(txtwidth(loControl.caption,loControl.fontname,loControl.fontsize)+2) * ;
                         fontmetric(6,loControl.fontname,loControl.fontsize)+3 && Width of caption
               endif
               exit  && No need to ck the other controls
          endfor

          loColumn.width=round(max(lnFWidth*fontmetric(6,loColumn.fontname,loColumn.fontsize),lnCWidth),0)
          lnWidthTotal=lnWidthTotal+loColumn.width
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform