******************************************************************** * Description.......: wgGrid.FormatAndSetCaption - format all grid columns and set caption to be in Proper format * Calling Samples...: * Parameter List....: * Created by........: Nadya Nosonovsky 03/09/2000 02:03:22 PM * Modified by.......: Nadya Nosonovsky 03/29/2000 01:37:26 PM ******************************************************************** local loColumn, loControl, lnWidthTotal, lnSel, ; lnFWidth, lnCWidth, lcFieldName, lcFieldType lnSel=select() && save current area 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 ** Nadya Nosonovsky 03/29/2000 01:35:47 PM added Incremental Search (could be added for ReadOnly grid) if this.lIncremental and lcFieldType='C' && We would use this feature only for char fields if lower(loColumn.currentcontrol)='text1' && standard text1 control loColumn.removeobject('text1') loColumn.newobject('text1','ingrid','wgcontrols.vcx') && Incremental search textbox loColumn.text1.visible=.t. *loColumn.ReadOnly=.t. && this is necessary condition loColumn.text1.cLocateExpression='upper('+lcFieldName+')' endif endif * Nadya Nosonovsky 03/29/2000 01:36:17 PM added Show Memo if this.lShowMemo and lcFieldType='M' && We want to show Memo field if lower(loColumn.currentcontrol)='text1' && standard text1 control loColumn.removeobject('text1') loColumn.newobject('text1','edtexpand','wgcontrols.vcx') && expandable editbox loColumn.text1.visible=.t. loColumn.sparse=.f. endif endif endfor this.width=min(this.width,lnWidthTotal) endif select (lnSel) && return to previous area>>I stepped through the debugger a lot, checking every property on the grid textbox, and it appears that the .text value is always a single character, and is the first character of the column value. For example, if I look at the underlying table and the record pointer is on "Real Time Checking" then the value of GridGeneral1.Column1.Text1.Text = "R".